Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New-SelfSignedCertificateEx -Subject "CN=TestCA" -IsCA $true -ProviderName "Microsoft Software Key Storage Provider" -Exportable -customextension $extCollection #159

Closed
ckrueger1979 opened this issue Sep 9, 2021 · 6 comments
Labels
bug Bug. An issue exist in our code. fixed-vNext The item is fixed in development code. Will be available in next release.

Comments

@ckrueger1979
Copy link

ckrueger1979 commented Sep 9, 2021

Hi Vadims,

is this a bug or is my extension wrong?

Import-Module pspki

$permittedSubtree = New-Object System.Security.Cryptography.X509Certificates.X509AlternativeNameCollection
$dnsType = [System.Security.Cryptography.X509Certificates.X509AlternativeNamesEnum]::DnsName
$corpDomains = New-Object System.Security.Cryptography.X509Certificates.X509AlternativeName $dnsType,"example.com"
$excludedSubtree = New-Object System.Security.Cryptography.X509Certificates.X509AlternativeNameCollection
[void] $excludedSubtree.Add($corpDomains)
$nameConstraintExt = New-Object System.Security.Cryptography.X509Certificates.X509NameConstraintsExtension $permittedSubtree,$excludedSubtree
$nameConstraintExt.Critical = $true

$extCollection = New-Object System.Security.Cryptography.X509Certificates.X509ExtensionCollection
[void] $extCollection.Add($nameConstraintExt)

New-SelfSignedCertificateEx -Subject "CN=TestCA" -IsCA $true -ProviderName "Microsoft Software Key Storage Provider" -Exportable -customextension $extCollection

New-SelfSignedCertificateEx : Exception calling "Build" with "1" argument(s): "Index was outside the bounds of the array."
At line:1 char:1

@Crypt32
Copy link
Collaborator

Crypt32 commented Sep 9, 2021

Can you provide a full stack trace of the exception by calling the following line immediately after exception is thrown:

$error[0].Exception.InnerException.StackTrace

@ckrueger1979
Copy link
Author

PS C:\> $error[0].Exception.InnerException.StackTrace
   at System.Security.Cryptography.X509Certificates.X509AlternativeName.decodeFromRawData(Byte[] asnData) in c:\temp\pkix.net\PKI\Cryptography\X509Certificates\X509AlternativeName.cs:line 426
   at System.Security.Cryptography.X509Certificates.X509NameConstraintsExtension.decodeNamesFromAsn(Byte[] rawData) in c:\temp\pkix.net\PKI\Cryptography\X509Certificates\X509NameConstraintsExtension.cs:line 103
   at System.Security.Cryptography.X509Certificates.X509NameConstraintsExtension.m_decode(Byte[] rawData) in c:\temp\pkix.net\PKI\Cryptography\X509Certificates\X509NameConstraintsExtension.cs:line 79
   at PKI.Utils.CryptographyUtils.ConvertExtension(X509Extension extension) in c:\temp\pkix.net\PKI\Utils\CryptographyUtils.cs:line 61
   at SysadminsLV.PKI.Cryptography.X509Certificates.X509CertificateBuilder.processExtensions() in c:\temp\pkix.net\PKI\Cryptography\X509Certificates\X509CertificateBuilder.cs:line 130
   at SysadminsLV.PKI.Cryptography.X509Certificates.X509CertificateBuilder.Build(X509Certificate2 signer) in c:\temp\pkix.net\PKI\Cryptography\X509Certificates\X509CertificateBuilder.cs:line 217
   at CallSite.Target(Closure , CallSite , Object , X509Certificate2 )

@Crypt32
Copy link
Collaborator

Crypt32 commented Sep 9, 2021

Thanks, I will take a look into this.

Crypt32 added a commit to PKISolutions/pkix.net that referenced this issue Sep 9, 2021
@Crypt32
Copy link
Collaborator

Crypt32 commented Sep 9, 2021

I can confirm the bug. It is fixed in sources, see this commit: PKISolutions/pkix.net@8b808e0

@Crypt32 Crypt32 added bug Bug. An issue exist in our code. fixed-vNext The item is fixed in development code. Will be available in next release. labels Sep 9, 2021
@ckrueger1979
Copy link
Author

Waow, that was fast. Thanks!

@Crypt32
Copy link
Collaborator

Crypt32 commented Jun 15, 2023

Fixed in v4.0.0

@Crypt32 Crypt32 closed this as completed Jun 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug. An issue exist in our code. fixed-vNext The item is fixed in development code. Will be available in next release.
Projects
None yet
Development

No branches or pull requests

2 participants