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

Exception calling "GetResult" with "0" argument(s): "An error occurred while sending the request." #123

Open
haviay opened this issue Aug 21, 2021 · 6 comments
Assignees
Labels
question Further information is requested

Comments

@haviay
Copy link

haviay commented Aug 21, 2021

Hi,
I got this error:

Exception calling "GetResult" with "0" argument(s): "An error occurred while sending the request."
At C:\...\WindowsPowerShell\Modules\ACME-PS\1.2.3\ACME-PS.psm1:3256 char:13
             throw [AcmeHttpException]::new($response.ErrorMessage, $r ...

     CategoryInfo          : OperationStopped: (:) [], AcmeHttpException
     FullyQualifiedErrorId : Exception calling "GetResult" with "0" argument(s): "An error occurred while sending the
    request."

At C:\...\Documents\WindowsPowerShell\Modules\ACME-PS\1.2.3\ACME-PS.psm1:3256 char:13
            throw [AcmeHttpException]::new($response.ErrorMessage, $r ...

     CategoryInfo          : OperationStopped: (:) [], AcmeHttpException
     FullyQualifiedErrorId : Exception calling "GetResult" with "0" argument(s): "An error occurred while sending the
    request."

while I run this code(it worked for me many times before):


$documentRoot = "C:\...\prod_Routing.Valoreti";
$acmeServiceName = "LetsEncrypt";

$contactMailAddresses = @("[email protected]");

$acmeStateDir = "C:\CertsV2\c01\pfx\$certname.pfx";
$certFile = "C:\CertsV2\c01\pfx\woily1-$(get-date -format yyyy-MM-dd--HH-mm).pfx";



Import-Module 'ACME-PS';

$dnsIdentifiers = @("aaa.com", "bbb.com"	)


$order = New-ACMEOrder -State $acmeStateDir -Identifiers $dnsIdentifiers;

if ($null -eq $order) { # Will fetch the order
    $order = Find-ACMEOrder -State $acmeStateDir -Identifiers $dnsIdentifiers;
}
$authorizations = @(Get-ACMEAuthorization -State $acmeStateDir -Order $order);

foreach($authz in $authorizations) {
    $challenge = Get-ACMEChallenge -State $acmeStateDir -Authorization $authZ -Type "http-01";
    $chFilename = $documentRoot + $challenge.Data.RelativeUrl;
    $chDirectory = [System.IO.Path]::GetDirectoryName($chFilename);
 
    if(-not (Test-Path $chDirectory)) {
        New-Item -Path $chDirectory -ItemType Directory;
    }

    Set-Content -Path $chFilename -Value $challenge.Data.Content -NoNewline;  
   
    $challenge | Complete-ACMEChallenge -State $acmeStateDir;
}

while($order.Status -notin ("ready","invalid")) {
    Start-Sleep -Seconds 10;
    $order | Update-ACMEOrder -State $acmeStateDir -PassThru;
}

if($order.Status -ieq ("invalid")) {
    $order | Get-ACMEAuthorizationError -State $acmeStateDir;
    throw "Order was invalid";
}

Complete-ACMEOrder -State $acmeStateDir -Order $order -GenerateCertificateKey;
while(-not $order.CertificateUrl) {
    Start-Sleep -Seconds 15
    $order | Update-ACMEOrder -State $acmeStateDir -PassThru
}

Export-ACMECertificate -State $acmeStateDir -Order $order -Path $certFile;

Import-PFXCertificate -FilePath $certFile -CertStoreLocation Cert:\LocalMachine\My


@haviay haviay added the question Further information is requested label Aug 21, 2021
@glatzert
Copy link
Collaborator

The error might indicate "no-internet connection".
Also current version is 1.5.0 - perhaps you might want to upgrade.

@haviay
Copy link
Author

haviay commented Aug 22, 2021

Thakns @glatzert
I think there is no problem with the internet connection.
Which address and port to check connection with telnet?

@glatzert
Copy link
Collaborator

glatzert commented Aug 22, 2021 via email

@haviay
Copy link
Author

haviay commented Aug 22, 2021

I don't see connection errors
The error occurred after this line:
$order = New-ACMEOrder -State $acmeStateDir -Identifiers $dnsIdentifiers;

This is the Verbose output:

VERBOSE: Performing the operation "Create new order with ACME Service" on target "Order".
VERBOSE: Importing object from CLIXML file C:\...\AccountKey.xml
VERBOSE: Converted input object to type RSAKeyExport
VERBOSE: Importing object from CLIXML file C:\...\.pfx\Account.xml
VERBOSE: Converted input object to type AcmeAccount
VERBOSE: Sending HttpRequest (POST) to https://acme-v02.api.letsencrypt.org/acme/new-order

This is the output of the command
Invoke-WebRequest https://acme-v02.api.letsencrypt.org/acme/new-order


Invoke-WebRequest : The request was aborted: Could not create SSL/TLS secure channel.
At line:1 char:1
Invoke-WebRequest https://acme-v02.api.letsencrypt.org/acme/new-order

CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebException
FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand

@glatzert
Copy link
Collaborator

glatzert commented Aug 22, 2021 via email

@haviay
Copy link
Author

haviay commented Aug 22, 2021

Thanks @glatzert
I found the solution
i just added this code line and it was fixed
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants