Guest User

Untitled

a guest
Jan 21st, 2018
311
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. var client = new LetsEncryptClient(LetsEncryptClient.StagingV2);
  2. await client.Init("your-email@example.com", CancellationToken.None);
  3. var tos = client.GetTermsOfServiceUri(); // user should agree to this
  4.  
  5. // start a new order for the *.example.net wildcard domain
  6. Dictionary<string,string> challenges = await client.NewOrder(new[]
  7. {
  8. "*.example.net"
  9. });
  10.  
  11. // do the DNS challenge
  12. foreach(var challenge in challenges)
  13. {
  14. await UpdateDnsServer(host: "_acme-challenge." + challenge.Key, token: challenge.Value, recordType: "TXT");
  15. }
  16.  
  17. // Now that the DNS is updated, let Let's Encrypt know that it can validate them
  18. await client.CompleteChallenges();
  19.  
  20. // get the certificate for the successful order
  21. var cert = await client.GetCertificate();
  22. //combine public cert with the private key for a full pfx
  23. var pfx = cert.Cert.CopyWithPrivateKey(cert.PrivateKey);
  24. File.WriteAllBytes("wildcard.example.net.pfx", pfx.Export(X509ContentType.Pfx));
Add Comment
Please, Sign In to add comment