Skip to content

Commit

Permalink
fix some issues
Browse files Browse the repository at this point in the history
  • Loading branch information
romanett committed Jan 15, 2025
1 parent 65ee40c commit 29eb65a
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Libraries/Opc.Ua.Gds.Server.Common/ApplicationsNodeManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1123,7 +1123,7 @@ private ServiceResult OnStartSigningRequest(
byte[] certificateRequest,
ref NodeId requestId)
{
AuthorizationHelper.HasAuthorization(context, AuthorizationHelper.CertificateAuthorityAdminOrSelfAdmin, applicationId); ;
AuthorizationHelper.HasAuthorization(context, AuthorizationHelper.CertificateAuthorityAdminOrSelfAdmin, applicationId);

var application = m_database.GetApplication(applicationId);

Expand Down Expand Up @@ -1230,7 +1230,7 @@ private ServiceResult OnFinishRequest(
}

ICertificateGroup certificateGroup = null;
if (!String.IsNullOrWhiteSpace(certificateGroupId))
if (!string.IsNullOrWhiteSpace(certificateGroupId))
{
foreach (var group in m_certificateGroups)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,10 @@ private bool VerifyForRSA(X509Certificate2 certificate, RSASignaturePadding padd
{
using (RSA rsa = certificate.GetRSAPublicKey())
{
if (rsa == null)
{
return false;

Check warning on line 195 in Libraries/Opc.Ua.Security.Certificates/X509Crl/X509Signature.cs

View check run for this annotation

Codecov / codecov/patch

Libraries/Opc.Ua.Security.Certificates/X509Crl/X509Signature.cs#L195

Added line #L195 was not covered by tests
}
return rsa.VerifyData(Tbs, Signature, Name, padding);
}
}
Expand All @@ -201,6 +205,10 @@ private bool VerifyForECDsa(X509Certificate2 certificate)
{
using (ECDsa key = certificate.GetECDsaPublicKey())
{
if (key == null)
{
return false;

Check warning on line 210 in Libraries/Opc.Ua.Security.Certificates/X509Crl/X509Signature.cs

View check run for this annotation

Codecov / codecov/patch

Libraries/Opc.Ua.Security.Certificates/X509Crl/X509Signature.cs#L210

Added line #L210 was not covered by tests
}
byte[] decodedSignature = DecodeECDsa(Signature, key.KeySize);
return key.VerifyData(Tbs, decodedSignature, Name);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,12 @@ private ServiceResult UpdateCertificate(
throw new ServiceResultException(StatusCodes.BadCertificateInvalid, "Certificate data is invalid.");
}

// validate certificate type of new certificate
if (!CertificateIdentifier.ValidateCertificateType(newCert, certificateTypeId))
{
throw new ServiceResultException(StatusCodes.BadCertificateInvalid, "Certificate type of new certificate doesn't match the provided certificate type.");

Check warning on line 430 in Libraries/Opc.Ua.Server/Configuration/ConfigurationNodeManager.cs

View check run for this annotation

Codecov / codecov/patch

Libraries/Opc.Ua.Server/Configuration/ConfigurationNodeManager.cs#L430

Added line #L430 was not covered by tests
}

// identify the existing certificate to be updated
// it should be of the same type and same subject name as the new certificate
CertificateIdentifier existingCertIdentifier = certificateGroup.ApplicationCertificates.FirstOrDefault(cert =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ public X509Certificate2Collection LoadCertificateChain(X509Certificate2 certific
public void Update(SecurityConfiguration securityConfiguration)
{
m_securityConfiguration = securityConfiguration;
m_certificateChain.Clear();
//ToDo intialize internal CertificateValidator after Certificate Update to clear cache of old application certificates
}

Expand Down

0 comments on commit 29eb65a

Please sign in to comment.