mirror of
https://github.com/OPCFoundation/UA-.NETStandard.git
synced 2026-10-20 16:52:07 +08:00
GDS Server fixes for 1.05.02 and .NET 4.8 (#1973)
* Fix for ReadTrustList test failure. * fix .NET4.8 GDS push * include .NET 4.8 in test pipeline * fix audit event that may throw exception when server is halted Co-authored-by: Randy Armstrong <randy@sparhawksoftware.com>
This commit is contained in:
@@ -125,15 +125,7 @@ namespace Opc.Ua.Security.Certificates
|
||||
if (publicKey == null) throw new ArgumentNullException(nameof(publicKey));
|
||||
try
|
||||
{
|
||||
var asymmetricKeyParameter = PublicKeyFactory.CreateKey(publicKey);
|
||||
var rsaKeyParameters = asymmetricKeyParameter as RsaKeyParameters;
|
||||
var parameters = new RSAParameters {
|
||||
Exponent = rsaKeyParameters.Exponent.ToByteArrayUnsigned(),
|
||||
Modulus = rsaKeyParameters.Modulus.ToByteArrayUnsigned()
|
||||
};
|
||||
RSA rsaPublicKey = RSA.Create();
|
||||
rsaPublicKey.ImportParameters(parameters);
|
||||
m_rsaPublicKey = rsaPublicKey;
|
||||
m_rsaPublicKey = X509Utils.SetRSAPublicKey(publicKey);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
@@ -191,6 +191,22 @@ namespace Opc.Ua.Security.Certificates.BouncyCastle
|
||||
return Convert.ToBase64String(tokenBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a RSA object with an imported public key.
|
||||
/// </summary>
|
||||
internal static RSA SetRSAPublicKey(byte[] publicKey)
|
||||
{
|
||||
var asymmetricKeyParameter = PublicKeyFactory.CreateKey(publicKey);
|
||||
var rsaKeyParameters = asymmetricKeyParameter as RsaKeyParameters;
|
||||
var parameters = new RSAParameters {
|
||||
Exponent = rsaKeyParameters.Exponent.ToByteArrayUnsigned(),
|
||||
Modulus = rsaKeyParameters.Modulus.ToByteArrayUnsigned()
|
||||
};
|
||||
RSA rsaPublicKey = RSA.Create();
|
||||
rsaPublicKey.ImportParameters(parameters);
|
||||
return rsaPublicKey;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -295,14 +295,16 @@ namespace Opc.Ua.Security.Certificates
|
||||
public override ICertificateBuilderCreateForRSAAny SetRSAPublicKey(byte[] publicKey)
|
||||
{
|
||||
if (publicKey == null) throw new ArgumentNullException(nameof(publicKey));
|
||||
#if NET472_OR_GREATER
|
||||
throw new NotSupportedException("Import a RSAPublicKey is not supported on this platform.");
|
||||
#else
|
||||
int bytes = 0;
|
||||
try
|
||||
{
|
||||
#if NET472_OR_GREATER
|
||||
m_rsaPublicKey = BouncyCastle.X509Utils.SetRSAPublicKey(publicKey);
|
||||
bytes = publicKey.Length;
|
||||
#else
|
||||
m_rsaPublicKey = RSA.Create();
|
||||
m_rsaPublicKey.ImportSubjectPublicKeyInfo(publicKey, out bytes);
|
||||
#endif
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -314,7 +316,6 @@ namespace Opc.Ua.Security.Certificates
|
||||
throw new ArgumentException("Decoded the public key but extra bytes were found.");
|
||||
}
|
||||
return this;
|
||||
#endif
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -120,6 +120,7 @@ namespace Opc.Ua.Server
|
||||
m_configuration = configuration;
|
||||
// TODO: configure cert groups in configuration
|
||||
ServerCertificateGroup defaultApplicationGroup = new ServerCertificateGroup {
|
||||
NodeId = Opc.Ua.ObjectIds.ServerConfiguration_CertificateGroups_DefaultApplicationGroup,
|
||||
BrowseName = Opc.Ua.BrowseNames.DefaultApplicationGroup,
|
||||
CertificateTypes = new NodeId[] { ObjectTypeIds.RsaSha256ApplicationCertificateType },
|
||||
ApplicationCertificate = configuration.SecurityConfiguration.ApplicationCertificate,
|
||||
@@ -200,7 +201,8 @@ namespace Opc.Ua.Server
|
||||
|
||||
case ObjectTypes.CertificateGroupType:
|
||||
{
|
||||
var result = m_certificateGroups.FirstOrDefault(group => group.BrowseName == passiveNode.BrowseName);
|
||||
var result = m_certificateGroups.FirstOrDefault(group => group.NodeId == passiveNode.NodeId);
|
||||
|
||||
if (result != null)
|
||||
{
|
||||
CertificateGroupState activeNode = new CertificateGroupState(passiveNode.Parent);
|
||||
|
||||
@@ -1224,9 +1224,17 @@ namespace Opc.Ua.Server
|
||||
{
|
||||
exception = exception.InnerException;
|
||||
}
|
||||
|
||||
if (exception is ServiceResultException sre)
|
||||
{
|
||||
statusCode = sre.InnerResult.StatusCode;
|
||||
if (sre.InnerResult != null)
|
||||
{
|
||||
statusCode = sre.InnerResult.StatusCode;
|
||||
}
|
||||
else
|
||||
{
|
||||
statusCode = sre.StatusCode;
|
||||
}
|
||||
}
|
||||
|
||||
ISystemContext systemContext = server.DefaultAuditContext;
|
||||
|
||||
@@ -64,6 +64,12 @@ stages:
|
||||
framework: net462
|
||||
agents: '@{ windows = "windows-2019" }'
|
||||
jobnamesuffix: net462
|
||||
- template: .azurepipelines/test.yml
|
||||
parameters:
|
||||
configuration: Release
|
||||
framework: net48
|
||||
agents: '@{ windows = "windows-2019" }'
|
||||
jobnamesuffix: net48
|
||||
- template: .azurepipelines/test.yml
|
||||
parameters:
|
||||
configuration: Release
|
||||
|
||||
Reference in New Issue
Block a user