1
0
mirror of synced 2025-01-31 04:13:43 +01:00

Test linux cert, change event download url

This commit is contained in:
asesidaa 2022-08-06 14:30:42 +08:00
parent c21047024c
commit aea09c2c8b
2 changed files with 26 additions and 6 deletions

View File

@ -15,7 +15,7 @@ namespace GCLocalServerRewrite.controllers;
public class ServerController : WebApiController
{
private static readonly string DataUrl = $"https://{Configs.SETTINGS.ServerIp}/{Configs.STATIC_FOLDER}/{Configs.SETTINGS.EventFolder}";
private static readonly string DataUrl = $"https://cert.nesys.jp/{Configs.STATIC_FOLDER}/{Configs.SETTINGS.EventFolder}";
[Route(HttpVerbs.Get, "/certify.php")]
public string Certify([QueryData] NameValueCollection parameters)

View File

@ -1,4 +1,5 @@
using EmbedIO;
using System.Security.Cryptography.X509Certificates;
using EmbedIO;
using EmbedIO.Actions;
using EmbedIO.Files;
using EmbedIO.WebApi;
@ -7,6 +8,7 @@ using GCLocalServerRewrite.controllers;
using GCLocalServerRewrite.models;
using Swan.Logging;
using System.Text;
using Swan;
namespace GCLocalServerRewrite.server;
@ -15,12 +17,30 @@ public class Server
public static WebServer CreateWebServer(IEnumerable<string> urlPrefixes)
{
InitializeDatabase();
var cert = CertificateHelper.InitializeCertificate();
X509Certificate2 cert;
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
{
cert = CertificateHelper.InitializeCertificate();
}
else
{
var certPath = Path.Combine(PathHelper.CertRootPath, "cert.pfx");
var certPassword = string.Empty;
var collection = new X509Certificate2Collection();
collection.Import(certPath, null, X509KeyStorageFlags.PersistKeySet |
X509KeyStorageFlags.MachineKeySet |
X509KeyStorageFlags.Exportable);
if (!collection.Any())
{
SelfCheck.Failure("Failed to import certificate!!!");
}
cert = collection.First();
}
var server = new WebServer(webServerOptions => webServerOptions
.WithUrlPrefixes(urlPrefixes)
.WithCertificate(cert)
.WithMode(HttpListenerMode.EmbedIO))
.WithUrlPrefixes(urlPrefixes)
.WithCertificate(cert)
.WithMode(HttpListenerMode.EmbedIO))
.WithLocalSessionManager()
.WithCors()
.WithWebApi(Configs.API_BASE_ROUTE, module => module.WithController<ApiController>())