PKISharp / ACMESharpCore

An ACME v2 client library for .NET Standard (Let's Encrypt)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

System.Private.Uri: Value cannot be null when creating a new account

crhistianramirez opened this issue · comments

When I execute this code I get the following errors on await _client.GetNonceAsync(). Am I missing something?

Error:

System.Private.CoreLib: Exception while executing function: RenewCertificates. System.Private.Uri: Value cannot be null.
Parameter name: uriString.

// initialize client
var acmeApiUrl = new Uri("https://acme-staging-v02.api.letsencrypt.org/");
var acme = new AcmeProtocolClient(acmeApiUrl );

// verify directory.NewNonce exists
var directory = await _client.GetDirectoryAsync();
Console.WriteLine(directory.NewNonce); // https://acme-staging-v02.api.letsencrypt.org/acme/new-nonce

// get nonce, used to communicate w/ server
await _client.GetNonceAsync();

// make request to create account
var contactEmails = new string[] { "mailto:test@test.com" };
var account = await _client.CreateAccountAsync(contactEmails, termsOfServiceAgreed: true);
var accountKey = new WinmarkAccountKey {
    KeyType = _client.Signer.JwsAlg,
    KeyExport = _client.Signer.Export()
};

// store account details
Console.WriteLine(account);
Console.WriteLine(accountKey);
_client.Account = account;

After you get the directory, you need to assign it to the client, in your case:

_client.Directory = directory;