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

Cannot find type [Org.BouncyCastle.Security.SecureRandom] #56

Closed
dechutes opened this issue Jul 2, 2018 · 4 comments
Closed

Cannot find type [Org.BouncyCastle.Security.SecureRandom] #56

dechutes opened this issue Jul 2, 2018 · 4 comments

Comments

@dechutes
Copy link

@dechutes dechutes commented Jul 2, 2018

Hello,
I'm am trying out your code and did a install-module -name posh-acme to install the latest release (I haven't tried the development release yet). Then ran set-paserver le_stage and New-PACertificate '*.mydomainhere','mydomainhere' -accepttos -contact myemailhere -verbose Using my actual domain info for mydomainhere. it got to line "Creating new private key for the certificate request" and then started getting lots of errors. the first was:

New-Object : Cannot find type [Org.BouncyCastle.Security.SecureRandom]: verify that the assembly containing this type
is loaded.
At C:\Program Files\WindowsPowerShell\Modules\Posh-ACME\2.4.0\Private\New-Csr.ps1:38 char:20

  •     $sRandom = New-Object Org.BouncyCastle.Security.SecureRandom
    
  •                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidType: (:) [New-Object], PSArgumentException
    • FullyQualifiedErrorId : TypeNotFound,Microsoft.PowerShell.Commands.NewObjectCommand

They continue on in the same vein from there. I went to that site and it apprears to be a helper class your using? I checked and couldn't find any dependencies listed in your documentation or code to load from there site. Any recommendations?

Thanks so much for doing this and any help you can provide!

@dechutes

This comment has been minimized.

Copy link
Author

@dechutes dechutes commented Jul 2, 2018

Quick update. I found the RequiredAssemblies = @('lib\BouncyCastle.Crypto.dll') line and verified that that file was in that location.

@rmbolger

This comment has been minimized.

Copy link
Owner

@rmbolger rmbolger commented Jul 2, 2018

This issue almost always revolves around the .NET Framework version installed on your system. The module requires .NET 4.7.1 or later which is also specified in the module manifest. But it looks like PowerShell doesn't enforce that for some reason. I really need to throw a manual check in there or something.

Here's a Microsoft page describing how to check what version of .NET you have installed by querying the registry. Here's an adapted one liner you can use to check:

(gp "HKLM:SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full").Release

The value needs to be 461308 or greater to indicate that you have .NET 4.7.1 or later.

P.S. The primary reason you need .NET 4.7.1 is because the Bouncy Castle library I'm using is compiled against .NET Standard 2.0 which is technically to compatible with .NET 4.6.1. But my understanding is that .NET 4.6.1 apps have to be compiled with explicit support for it (which PowerShell is not) and only as of .NET 4.7.1 will all apps work with it. Suffice to say, it's kind of a confusing mess right now in the .NET world.

@dechutes

This comment has been minimized.

Copy link
Author

@dechutes dechutes commented Jul 2, 2018

Thanks for the info. I will check on that and get back with you!

@dechutes

This comment has been minimized.

Copy link
Author

@dechutes dechutes commented Jul 2, 2018

Yep, that was it. Sorry about that. Thanks for your help!

@dechutes dechutes closed this Jul 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.