Skip to content

Commit

Permalink
fix tests on net 462
Browse files Browse the repository at this point in the history
  • Loading branch information
romanett committed Feb 3, 2025
1 parent 012e6de commit 81240c6
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 24 deletions.
43 changes: 25 additions & 18 deletions Tests/Opc.Ua.Gds.Tests/PushTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -511,27 +511,31 @@ public void UpdateCertificateSelfSigned(string keyFormat)

X509Certificate2 newCert;

#if ECC_SUPPORT
ECCurve? curve = EccUtils.GetCurveFromCertificateTypeId(m_certificateType);

// RSA Certificate
if (curve == null)
if (curve != null)
{
newCert = CertificateFactory.CreateCertificate(
m_applicationRecord.ApplicationUri,
m_applicationRecord.ApplicationNames[0].Text,
m_selfSignedServerCert.Subject + "1",
null).CreateForRSA();
m_applicationRecord.ApplicationUri,
m_applicationRecord.ApplicationNames[0].Text,
m_selfSignedServerCert.Subject + "1",
null)
.SetECCurve(curve.Value)
.CreateForECDsa();
}
// RSA Certificate
else
{
#endif
newCert = CertificateFactory.CreateCertificate(
m_applicationRecord.ApplicationUri,
m_applicationRecord.ApplicationNames[0].Text,
m_selfSignedServerCert.Subject + "1",
null)
.SetECCurve(curve.Value)
.CreateForECDsa();
null).CreateForRSA();
#if ECC_SUPPORT
}
#endif


byte[] privateKey = null;
Expand Down Expand Up @@ -935,27 +939,30 @@ private async Task CreateCATestCerts(string tempStorePath)
var certificateStoreIdentifier = new CertificateStoreIdentifier(tempStorePath, false);
Assert.IsTrue(EraseStore(certificateStoreIdentifier));
string subjectName = "CN=CA Test Cert, O=OPC Foundation";

#if ECC_SUPPORT
ECCurve? curve = EccUtils.GetCurveFromCertificateTypeId(m_certificateType);

// RSA Certificate
if (curve == null)
if (curve != null)
{
m_caCert = await CertificateFactory.CreateCertificate(
null, null, subjectName, null)
.SetCAConstraint()
.CreateForRSA()
.AddToStoreAsync(certificateStoreIdentifier).ConfigureAwait(false);
null, null, subjectName, null)
.SetCAConstraint()
.SetECCurve(curve.Value)
.CreateForECDsa()
.AddToStoreAsync(certificateStoreIdentifier).ConfigureAwait(false);
}
// RSA Certificate
else
{
#endif
m_caCert = await CertificateFactory.CreateCertificate(
null, null, subjectName, null)
.SetCAConstraint()
.SetECCurve(curve.Value)
.CreateForECDsa()
.CreateForRSA()
.AddToStoreAsync(certificateStoreIdentifier).ConfigureAwait(false);
#if ECC_SUPPORT
}
#endif

// initialize cert revocation list (CRL)
X509CRL newCACrl = await CertificateGroup.RevokeCertificateAsync(certificateStoreIdentifier, m_caCert).ConfigureAwait(false);
Expand Down
17 changes: 11 additions & 6 deletions Tests/Opc.Ua.Security.Certificates.Tests/CRLTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,22 +87,27 @@ public CRLTests(string certificateTypeString, NodeId certificateType)
[OneTimeSetUp]
protected void OneTimeSetUp()
{
#if ECC_SUPPORT
ECCurve? curve = EccUtils.GetCurveFromCertificateTypeId(m_certificateType);

// RSA Certificate
if (curve == null)
if (curve != null)
{
m_issuerCert = CertificateBuilder.Create("CN=Root CA, O=OPC Foundation")
.SetCAConstraint()
.CreateForRSA();
.SetECCurve(curve.Value)
.CreateForECDsa();

}
// RSA Certificate
else
{
#endif
m_issuerCert = CertificateBuilder.Create("CN=Root CA, O=OPC Foundation")
.SetCAConstraint()
.SetECCurve(curve.Value)
.CreateForECDsa();
.SetCAConstraint()
.CreateForRSA();
#if ECC_SUPPORT
}
#endif
}

/// <summary>
Expand Down

0 comments on commit 81240c6

Please sign in to comment.