rmbolger / Posh-ACME

PowerShell module and ACME client to create certificates from Let's Encrypt (or other ACME CA)
https://poshac.me/docs/latest/
MIT License
763 stars 186 forks source link

Unable to find type [AcmeException] #215

Closed rpmrmartin closed 4 years ago

rpmrmartin commented 4 years ago

Thank you for writing this great PowerShell module.

I am trying to run a pretty simple example:

Set-PAServer LE_STAGE

$goDaddyParameters = @{
    GDKey = 'xxx'
    GDSecret = 'xxx'
}

New-PACertificate test.ourdomain.com -DnsPlugin GoDaddy -PluginArgs $goDaddyParameters -Verbose

Here is the output:

VERBOSE: Using directory https://acme-staging-v02.api.letsencrypt.org/directory
VERBOSE: Creating a new ec-256 account with contact: 
WARNING: No email contacts specified for this account. Certificate expiration warnings will not be sent unless you add at least one with Set-PAAccount.
VERBOSE: POST https://acme-staging-v02.api.letsencrypt.org/acme/new-acct with -1-byte payload
Unable to find type [AcmeException].
At C:\Users\rmartin\OneDrive\Documents\WindowsPowerShell\Modules\Posh-ACME\3.12.0\Public\New-PAAccount.ps1:81 char:21
+ ...   $response = Invoke-ACME $header $payloadJson -Key $acctKey -EA Stop
+                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (AcmeException:TypeName) [Invoke-ACME], RuntimeException
    + FullyQualifiedErrorId : TypeNotFound,Invoke-ACME

I am using Windows PowerShell 5.1 on Windows 10 1809 with .NET Framework 4.8.

rmbolger commented 4 years ago

Hi @rpmrmartin. That's an odd error. Did you install the module via Install-Module or a direct download and extract?

There have been issues similar to this one previously on manually extracted installations because of a Windows feature that tags files downloaded from browsers with metadata that flags them as potentially unsafe. But usually that only affects loading types from the BouncyCastle library.

Can you also double check that in the module's folder, there's a Private folder with a file called AcmeException.ps1?

Last question. Do you know whether your PowerShell session is running in Constrained Language Mode or Just Enough Administration (JEA) mode? It looks like you can check by running $ExecutionContext.SessionState.LanguageMode.

rpmrmartin commented 4 years ago

Hi @rmbolger,

I installed the module via Install-Module. The PowerShell session was not running in Constrained Language Mode or Just Enough Administration mode.

Your module worked for me using PowerShell Core 6, so I was able to get my scripting done using that. After some re-installations, Windows PowerShell isn't giving me any problems either, so I guess that the module probably didn't get installed properly on Windows PowerShell. Thank you for your help.

rmbolger commented 4 years ago

No worries. Glad you got it sorted out.