Skip to content

Commit a46a1e7

Browse files
committed
Improved Certificate Importing
1 parent 3471648 commit a46a1e7

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

MLAPI/Data/NetworkConfig.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ public class NetworkConfig
142142
/// </summary>
143143
public bool SignKeyExchange = false;
144144
[TextArea]
145-
public string ServerCertificatePfx;
145+
public string ServerBase64PfxCertificate;
146146
public X509Certificate2 ServerX509Certificate
147147
{
148148
get

MLAPI/MonoBehaviours/Core/NetworkingManager.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,14 @@ private object Init(bool server)
298298

299299
try
300300
{
301-
if (server && !string.IsNullOrEmpty(NetworkConfig.ServerCertificatePfx)) NetworkConfig.ServerX509Certificate = new X509Certificate2(Convert.FromBase64String(NetworkConfig.ServerCertificatePfx));
301+
if (server && !string.IsNullOrEmpty(NetworkConfig.ServerBase64PfxCertificate))
302+
{
303+
NetworkConfig.ServerX509Certificate = new X509Certificate2(Convert.FromBase64String(NetworkConfig.ServerBase64PfxCertificate));
304+
if (!NetworkConfig.ServerX509Certificate.HasPrivateKey)
305+
{
306+
if (LogHelper.CurrentLogLevel <= LogLevel.Normal) LogHelper.LogWarning("The imported PFX file did not have a private key");
307+
}
308+
}
302309
}
303310
catch (CryptographicException ex)
304311
{

0 commit comments

Comments
 (0)