You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The call dotnet run -- createcertchain -s "My CA" -p mypassword -i 3
results in the following Runtime error:
Unhandled Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object.
at RW.DPSCertificateTool.CertificateUtil.CreateCaCertificate(String subjectName, String certificatePassword, X509Certificate2 issuingCa) in C:\source\local\AzureIoTDPSCertificates-master\AzureIoTDPSCertificates-master\src\DPSCertificateTool\CertificateUtil.cs:line 73
at RW.DPSCertificateTool.CreateCertChain.OnExecute() in C:\source\local\AzureIoTDPSCertificates-master\AzureIoTDPSCertificates-master\src\DPSCertificateTool\CreateCertChain.cs:
The text was updated successfully, but these errors were encountered:
I found the Problem and solution within the CreateCaCertificate-Method of the CertificateUtil-Class:
if (issuingCa != null)
{
// set the AuthorityKeyIdentifier. There is no built-in
// support, so it needs to be copied from the Subject Key
// Identifier of the signing certificate and massaged slightly.
// AuthorityKeyIdentifier is "KeyID="
// var issuerSubjectKey = issuingCa.Extensions["Subject Key Identifier"].RawData; byte[] issuerSubjectKey = null;
foreach (var item in issuingCa.Extensions)
{
if(item.Oid.Value == "2.5.29.14")
{
issuerSubjectKey = item.RawData;
break;
}
}
var segment = new ArraySegment<byte>(issuerSubjectKey, 2, issuerSubjectKey.Length - 2);
var authorityKeyIdentifier = new byte[segment.Count + 4];
// these bytes define the "KeyID" part of the AuthorityKeyIdentifer
authorityKeyIdentifier[0] = 0x30;
authorityKeyIdentifier[1] = 0x16;
authorityKeyIdentifier[2] = 0x80;
authorityKeyIdentifier[3] = 0x14;
segment.CopyTo(authorityKeyIdentifier, 4);
request.CertificateExtensions.Add(new X509Extension("2.5.29.35", authorityKeyIdentifier, false));
} [Configuration.CA].RawData;
Sorry for the late response, I've been offline on vacation.
I am unable to reproduce the problem. The extension with OID 2.5.29.14 is "Subject Key Identifier" (as you already knew).
I don't know why that shouldn't have a name on your computer, or has it perhaps been localized?
What are the properties of the 2.5.29.14 extension on your computer, specifically the item.Oid.FriendlyName ?
The call
dotnet run -- createcertchain -s "My CA" -p mypassword -i 3
results in the following Runtime error:
Unhandled Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object.
at RW.DPSCertificateTool.CertificateUtil.CreateCaCertificate(String subjectName, String certificatePassword, X509Certificate2 issuingCa) in C:\source\local\AzureIoTDPSCertificates-master\AzureIoTDPSCertificates-master\src\DPSCertificateTool\CertificateUtil.cs:line 73
at RW.DPSCertificateTool.CreateCertChain.OnExecute() in C:\source\local\AzureIoTDPSCertificates-master\AzureIoTDPSCertificates-master\src\DPSCertificateTool\CreateCertChain.cs:
The text was updated successfully, but these errors were encountered: