Add certificate params to main config
This commit is contained in:
parent
7637140aad
commit
0f1eec56fb
3 changed files with 21 additions and 3 deletions
|
@ -6,7 +6,7 @@ using System.Reflection;
|
|||
[assembly: AssemblyCompany("ZNI")]
|
||||
[assembly: AssemblyAlgorithmId(System.Configuration.Assemblies.AssemblyHashAlgorithm.MD5)]
|
||||
[assembly: AssemblyCopyright("© 2020 Tara Piccari")]
|
||||
[assembly: AssemblyFileVersion("5.1.960")]
|
||||
[assembly: AssemblyFileVersion("5.1.961")]
|
||||
[assembly: AssemblyDescription("Second Life Bot - BotCore5")]
|
||||
|
||||
|
||||
|
@ -15,7 +15,7 @@ namespace Bot.Assemble
|
|||
public class ASMInfo
|
||||
{
|
||||
public static string BotName = "ZBotCore";
|
||||
public static string BotVer = "5.1.960";
|
||||
public static string BotVer = "5.1.961";
|
||||
public static string GitPassword
|
||||
{
|
||||
get
|
||||
|
|
|
@ -63,6 +63,8 @@ namespace Bot
|
|||
public string WebServerIP { get; set; } = "zontreck.dev";
|
||||
|
||||
public bool UseSSL { get; set; } = false;
|
||||
public string SSLCertificatePFX { get; set; } = "certificate.pfx";
|
||||
public string SSLCertificatePWD { get; set; } = "";
|
||||
|
||||
public Dictionary<UUID, int> BotAdmins { get; set; } = new Dictionary<UUID, int>();
|
||||
|
||||
|
|
|
@ -17,6 +17,8 @@ using System.IO;
|
|||
using System.Net.Http;
|
||||
using System.Net;
|
||||
using Newtonsoft.Json;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Bot.WebHookServer
|
||||
{
|
||||
|
@ -58,12 +60,26 @@ namespace Bot.WebHookServer
|
|||
try
|
||||
{
|
||||
listener = new HttpListener();
|
||||
MHEx = MH.callbacks;
|
||||
|
||||
if (MainConfiguration.Instance.UseSSL)
|
||||
{
|
||||
|
||||
X509Certificate cert = new X509Certificate2(MainConfiguration.Instance.SSLCertificatePFX, MainConfiguration.Instance.SSLCertificatePWD);
|
||||
|
||||
Type hepmType = Type.GetType("System.Net.HttpEndPointManager, System.Net.HttpListener");
|
||||
Type heplType = Type.GetType("System.Net.HttpEndPointListener, System.Net.HttpListener");
|
||||
MethodInfo getEPListener = hepmType.GetMethod("GetEPListener", BindingFlags.Static | BindingFlags.NonPublic);
|
||||
FieldInfo heplCert = heplType.GetField("_cert", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
object epl = getEPListener.Invoke(null, new object[] { "+", MainConfiguration.Instance.WebServerPort, listener, true });
|
||||
heplCert.SetValue(epl, cert);
|
||||
listener.Prefixes.Add($"https://*:{MainConfiguration.Instance.WebServerPort}/");
|
||||
}
|
||||
else
|
||||
listener.Prefixes.Add($"http://*:{MainConfiguration.Instance.WebServerPort}/");
|
||||
|
||||
|
||||
MHEx = MH.callbacks;
|
||||
|
||||
listener.Start();
|
||||
var hc = new HookCmds();
|
||||
hc.listener = listener;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue