Private Key missing in X509Certificate2 after creating certificate #2703
Replies: 1 comment 2 replies
-
hi @ahmadjqureshi , which platform are you using? windows or linux? .NET 8 or .NET Framework? |
Beta Was this translation helpful? Give feedback.
-
Hi Team,
The following code which was copied from UA.NETStandard 1.4.366.38 method CertificateFactory.CreateCertificate works correctly with OPCFoundation.NetStandard.Opc.Ua 1.4.370.12 but NOT with OPCFoundation.NetStandard.Opc.Ua 1.4.371.86 and later versions. The resulting X509Certificate2 certificate from method call “createBuilder.CreateForRSA();” does not contain private key despite HasPrivateKey property is true and PrivateKey property is null.
Is this some bug in OPCFoundation.NetStandard.Opc.Ua or is there any other way to create certificate including private key?
private static X509Certificate2 CertificateFactoryCreateCertificate(string applicationUri, string applicationName, string subjectName, IList domainNames, ushort keySize, DateTime startTime, ushort lifetimeInMonths, ushort hashSizeInBits, bool isCA = false, X509Certificate2 issuerCAKeyCert = null, byte[] publicKey = null, int pathLengthConstraint = 0)
{
ICertificateBuilder builder = null;
if (isCA)
{
builder = CertificateFactory.CreateCertificate(subjectName);
}
else
{
builder = CertificateFactory.CreateCertificate(applicationUri, applicationName, subjectName, domainNames);
}
}
Beta Was this translation helpful? Give feedback.
All reactions