-
Notifications
You must be signed in to change notification settings - Fork 59
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 : Exception setting "ProviderName": #56
Comments
With the release of PSPKI v3.4.0.1 I am also experiencing this issue. Repro: Running the following command results in the same error as above and will even crash the PowerShell ISE:
Error:
|
I can confirm that this issue is reproduced on pre-Windows 10 and pre-Windows Server 2016 systems. When running the code on Windows 10 it is working as expected:
The issue is caused by this line (https://github.com/Crypt32/pkix.net/blob/5b0217f1b32897b21ce831ce2ca22c1a7cf912c4/PKI/Cryptography/X509PrivateKeyBuilder.cs#L14): |
Adding new info: it seems that there is a PowerShell issue as well. Trying the code on pre-Windows 10, the PowerShell console is crashed. Still investigating the issue. |
Ok, got more details. This issue is more serious than I thought initially. The fix provided in PKISolutions/pkix.net@71a2bed doesn't help much. The issue still persist. I made deeper investigation and found that Interop.CERTENROLL.dll interop library from Windows 10 (my development environment) is not compatible with previous versions. I will check if I can create interop library from previous OS versions. |
Resolved this issue. I was forced to make a new CertEnroll interop library from Windows 8.1/Windows Server 2012 R2 which doesn't include I'm accepting bugs till saturday (and which will most likely solved) and by monday I will release patch version (3.4.1) on PS Gallery. Here is patch version for you to test: |
Thanks for the update. Is it expected that the private KeyContainerName is returned even though the returned certificate object is stored in a variable? PS C:\Users > $certificate = New-SelfSignedCertificateEx @newSelfSignedCertificateExParameters I think this is due to a missing [void] calling a .net Method. Best regards |
no. It is an artifact from my testing at this line: https://github.com/Crypt32/pkix.net/blob/fad3f5c6fc08eaf79241464d477c3860dcd1420e/PKI/Tools/MessageOperations/MessageSigner.cs#L300. There was an issue with BTW, does patch version work for you? |
Good morning Vadims
Yes it does.
Windows Server 2012 R2.
Thank you.
Patrick
________________________________
Von: Vadims Podans <notifications@github.com>
Gesendet: Mittwoch, 17. Oktober 2018 21:42
An: Crypt32/PSPKI
Cc: PatrickOnGit; Comment
Betreff: Re: [Crypt32/PSPKI] New-SelfsignedCertificateEx : Exception setting "ProviderName": (#56)
Is it expected that the private KeyContainerName is returned even though the returned certificate object is stored in a variable?
no. It is an artifact from my testing at this line: https://github.com/Crypt32/pkix.net/blob/fad3f5c6fc08eaf79241464d477c3860dcd1420e/PKI/Tools/MessageOperations/MessageSigner.cs#L300. There was an issue with `NCryptOpenKey` function call which failed for me. I put `Console.WriteLine` to see if function parameters are correct. The issue was, actually, with `dwLegacyKeySpec` parameter.
BTW, does patch version work for you?
…--
You are receiving this because you commented.
Reply to this email directly or view it on GitHub:
#56 (comment)
|
Just tested your 'patched' version - all works well for me - THANK YOU! |
Maybe I spoke/typed too soon 👎 Tried another test on Windows Server 2012 R2 with all updates installed - Powershell v 5.0 - using your patch version from .zip above - here's what I see: PS C:\Users\Administrator> import-module c:\pspki $ADFSSelfSignedCertificateExParameters = @{ $adfscertificate = New-SelfSignedCertificateEx @ADFSSelfSignedCertificateExParameters ModuleType Version Name ExportedCommands Script 3.4.0.1 pspki {Add-AdCertificate, Add-AdCertificateRevocationList, Add...
This did work with previous versions The Good news is that your example that wouldn't work (again on WS2K12R2) prior to the patch .zip above now works OK: PS C:\Users\Administrator> $cert=New-SelfsignedCertificateEx -Subject "CN=Test Code Signing" -EKU "Code Signing" -KeySpec "Signature" ` lp-6dd5ca6a-078f-4fe7-bc8e-c155e6c443c1 PS C:\Users\Administrator> |
I will take a look. There is something wrong with machine context. If you specify store loacation as current user, the command will succeed. |
I fixed the last piece of the issue in this thread. @dnienhis tested your example and it now works in machine context as well. |
Update delivered to PS Gallery: https://www.powershellgallery.com/packages/PSPKI/3.4.1.0 |
I just downloaded the update - my test/example now works fine - thank you very much - however the examples from your help file are not quite so happy - unless i'm doing something wrong. Again, testing on W2K12R2 server. Here's the output: Windows PowerShell PS C:\Users\Administrator> uninstall-module pspki Untrusted repository ModuleType Version Name ExportedCommands Manifest 3.1.0.0 Microsoft.PowerShell.Management {Add-Computer, Add-Content, Checkpoint-Computer, Clear-Con... PS C:\Users\Administrator> import-module pspki ModuleType Version Name ExportedCommands Manifest 3.1.0.0 Microsoft.PowerShell.Management {Add-Computer, Add-Content, Checkpoint-Computer, Clear-Con... PS C:\Users\Administrator> New-SelfsignedCertificateEx -Subject "CN=Test Code Signing" -EKU "Code Signing" -KeySpec "Sig
Thumbprint Subject 215F1588C9B92322BF812FFFEF6D290115CCA7A3 CN=Test Code Signing PS C:\Users\Administrator> New-SelfsignedCertificateEx -Subject "CN=www.domain.com" -EKU "Server Authentication", "Clien
New-SelfSignedCertificateEx : Cannot process argument transformation on parameter 'KeyUsage'. Cannot convert value
PS C:\Users\Administrator> New-SelfsignedCertificateEx -Subject "CN=www.domain.com" -EKU "Server Authentication", "Clien
New-SelfSignedCertificateEx : Cannot process argument transformation on parameter 'KeyUsage'. Cannot convert value
PS C:\Users\Administrator> New-SelfsignedCertificateEx -Subject "CN=Test Root CA, OU=Sandbox" -IsCA $true -ProviderName
Thumbprint Subject 3ACB9201C37263D38D198DE29FCCD118F59E83EB CN=Test Root CA, OU=Sandbox PS C:\Users\Administrator> $ADFSSelfSignedCertificateExParameters = @{
PS C:\Users\Administrator> $adfscertificate = New-SelfSignedCertificateEx @ADFSSelfSignedCertificateExParameters |
I will update online help as soon as I can. |
In a given failed examples, there is a typo in "KeyEncipherment", help refers to "KeyEcipherment" with missed "n" character. Also, examples with "-File" parameter won't work (even though, it works, but must use parameters within selected parameter set). |
On a new/fresh install (and all Microsoft Updates Applied) Windows Server 2012 R2 Standard Server I did:
PS C:\Users\Administrator> Add-windowsfeature 'RSAT'
Success Restart Needed Exit Code Feature Result
True No Success {Hyper-V Module for Windows PowerShell, Hy...
PS C:\Users\Administrator> Install-Module -name 'PSPKI'
PS C:\Users\Administrator> Import-Module 'PSPKI'
PS C:\Users\Administrator> Get-Module -name 'PSPKI'
ModuleType Version Name ExportedCommands
Script 3.4.0.1 PSPKI {Add-AdCertificate, Add-AdCertificateRevocationList, Add...
Then attempted Example 1 in PSPKI Help for New-SelfSignedCertificateEx:
New-SelfsignedCertificateEx -Subject "CN=Test Code Signing" -EKU "Code Signing" -KeySpec "Signature" `
-KeyUsage "DigitalSignature" -FriendlyName "Test code signing" -NotAfter $((Get-Date).AddYears(5))
And Get this Error:
New-SelfsignedCertificateEx : Exception setting "ProviderName": "Unable to cast COM object of type
'CERTENROLLLib.CX509PrivateKeyClass' to interface type 'CERTENROLLLib.IX509PrivateKey2'. This operation failed
because the QueryInterface call on the COM component for the interface with IID
'{728AB362-217D-11DA-B2A4-000E7BBB2B09}' failed due to the following error: No such interface supported (Exception
from HRESULT: 0x80004002 (E_NOINTERFACE))."
At line:1 char:1
Also tried several of the other examples and get similar errors. I had been using your PSPKI module for quite some time with no problems - almost seems like related to most recent update but I could be wrong or doing something wrong?
PS C:> $psversiontable
Name Value
PSVersion 5.1.14409.1005
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.14409.1005
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
The text was updated successfully, but these errors were encountered: