Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions GenOnlineService/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
using Amazon.S3.Model;
using Microsoft.AspNetCore.Hosting.Server;
using Microsoft.EntityFrameworkCore;
using MySqlX.XDevAPI;
using Org.BouncyCastle.Tls;
using System;
using System.Collections.Concurrent;
using System.Diagnostics.Metrics;
Expand All @@ -32,7 +30,6 @@
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
using ZstdSharp.Unsafe;

namespace GenOnlineService
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
using Database;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using MySqlX.XDevAPI.Common;
using System;
using System.Net;
using System.Security.Cryptography;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using MySqlX.XDevAPI.Common;
using System;
using System.Net;
using System.Security.Cryptography;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options;
using MySqlX.XDevAPI.Common;
using Org.BouncyCastle.Tls;
using System;
using System.Net;
using System.Net.WebSockets;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Options;
using Org.BouncyCastle.Security;
using System;
using System.Collections.Concurrent;
using System.Net;
Expand Down
1 change: 0 additions & 1 deletion GenOnlineService/Controllers/OID/OIDController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options;
using Microsoft.IdentityModel.Tokens;
using MySqlX.XDevAPI.Common;
using System;
using System.IdentityModel.Tokens.Jwt;
using System.Net;
Expand Down
3 changes: 1 addition & 2 deletions GenOnlineService/Discord.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
using Discord.Rest;
using Discord.WebSocket;
using GenOnlineService;
using MySqlX.XDevAPI;
using System;
using System.Collections.Generic;
using System.Net.WebSockets;
Expand Down Expand Up @@ -848,4 +847,4 @@ public async Task PushMessage(SocketUser user, ulong channelToUse, string strMes

}
}
}
}
3 changes: 1 addition & 2 deletions GenOnlineService/GenOnlineService.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@
<PackageReference Include="Discord.Net" Version="3.20.1" />
<PackageReference Include="MaxMind.GeoIP2" Version="6.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="10.0.10" />
<PackageReference Include="MySql.Data" Version="9.7.0" />
<PackageReference Include="NSec.Cryptography" Version="26.4.0" />
<PackageReference Include="MySqlConnector" Version="2.4.0" />
<PackageReference Include="Polly" Version="8.7.0" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="9.0.0" />
<PackageReference Include="Sentry" Version="6.8.0" />
Expand Down
3 changes: 1 addition & 2 deletions GenOnlineService/LobbyManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
using Discord;
using GenOnlineService.Controllers;
using Microsoft.EntityFrameworkCore;
using MySqlX.XDevAPI;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
Expand Down Expand Up @@ -1763,4 +1762,4 @@ public bool IsUserInLobby(Lobby lobby, Int64 user_id)
return member != null;
}
}
}
}
3 changes: 1 addition & 2 deletions GenOnlineService/MatchmakingManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Options;
using Org.BouncyCastle.Tls;
using System;
using System.Collections.Concurrent;
using System.Net;
Expand Down Expand Up @@ -1547,4 +1546,4 @@ public static void DeregisterPlayer(UserSession plr)
Console.WriteLine("[Source 4] User {0} Leave Any Lobby", plr.m_UserID);
lobbyManager.LeaveAnyLobby(plr.m_UserID);
}
}
}
44 changes: 3 additions & 41 deletions GenOnlineService/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
** along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

using Google.Protobuf.WellKnownTypes;
using MaxMind.GeoIP2;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authentication.JwtBearer;
Expand All @@ -27,10 +26,6 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Options;
using Microsoft.IdentityModel.Tokens;
using Org.BouncyCastle.Crypto;
using Org.BouncyCastle.OpenSsl;
using Org.BouncyCastle.Pkcs;
using Org.BouncyCastle.Security;
using Sentry;
using System.Collections.Concurrent;
using System.Configuration;
Expand Down Expand Up @@ -144,37 +139,6 @@ public static bool ValidateKey(string strKey)
return bMatched;
}
}
public static class CertHelpers
{
public static X509Certificate2 LoadPemWithPrivateKey(string certPath, string keyPath)
{
using (var certReader = new StreamReader(certPath))
using (var keyReader = new StreamReader(keyPath))
{
var pemCertReader = new PemReader(certReader);
var pemKeyReader = new PemReader(keyReader);

var certificate = (Org.BouncyCastle.X509.X509Certificate)pemCertReader.ReadObject();
var privateKey = (AsymmetricKeyParameter)pemKeyReader.ReadObject();

//var store = new Pkcs12Store();
var store = new Pkcs12StoreBuilder().Build(); // Fix for CS1729
var certEntry = new X509CertificateEntry(certificate);
store.SetCertificateEntry("cert", certEntry);
store.SetKeyEntry("key", new AsymmetricKeyEntry(privateKey), new[] { certEntry });

using (var ms = new MemoryStream())
{
store.Save(ms, new char[0], new SecureRandom());
#pragma warning disable SYSLIB0057 // Type or member is obsolete
return new X509Certificate2(ms.ToArray(), string.Empty);
#pragma warning restore SYSLIB0057 // Type or member is obsolete
}
}
}
}


public class BasicAuthenticationHandler : AuthenticationHandler<AuthenticationSchemeOptions>
{
public BasicAuthenticationHandler(
Expand Down Expand Up @@ -400,7 +364,7 @@ private static async Task InitializeDatabase(WebApplicationBuilder builder)
string? password = dbSettings.GetValue<string>("db_password");
UInt16? port = dbSettings.GetValue<UInt16>("db_port");

// Fall back to MySql.Data's own defaults when a key is absent, rather than silently
// Fall back to MySqlConnector's own defaults when a key is absent, rather than silently
// disabling pooling / zeroing the pool size for deployments predating these settings.
int db_min_poolsize = dbSettings.GetValue<int?>("db_min_poolsize") ?? 0;
int db_max_poolsize = dbSettings.GetValue<int?>("db_max_poolsize") ?? 100;
Expand Down Expand Up @@ -444,7 +408,7 @@ private static async Task InitializeDatabase(WebApplicationBuilder builder)
{
//var builder = WebApplication.CreateBuilder(args);

var csb = new MySql.Data.MySqlClient.MySqlConnectionStringBuilder
var csb = new MySqlConnector.MySqlConnectionStringBuilder
{
Server = hostname,
Port = (uint)port,
Expand All @@ -453,7 +417,7 @@ private static async Task InitializeDatabase(WebApplicationBuilder builder)
Password = password,
ConnectionTimeout = (uint)db_connect_timeout,
DefaultCommandTimeout = (uint)db_command_timeout,
SslMode = MySql.Data.MySqlClient.MySqlSslMode.Preferred,
SslMode = MySqlConnector.MySqlSslMode.Preferred,
Pooling = db_use_pooling,
MinimumPoolSize = (uint)db_min_poolsize,
MaximumPoolSize = (uint)db_max_poolsize,
Expand Down Expand Up @@ -1091,8 +1055,6 @@ public static async Task Main(string[] args)
}
else
{
//X509Certificate2 = CertHelpers.LoadPemWithPrivateKey(cert_pem_path, cert_key_path);

X509Certificate2 = X509Certificate2.CreateFromPemFile(cert_pem_path, cert_key_path);


Expand Down
Loading