minor fixes and logic improvements

This commit is contained in:
root 2020-06-13 23:06:57 +02:00
parent 9b4d28ec64
commit 95305cfeb4
4 changed files with 21 additions and 16 deletions

View File

@ -1,13 +1,16 @@
using System; using System;
using System.IO; using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using Mono.Unix;
using LetsEncrypt.Services; using LetsEncrypt.Services;
using LetsEncrypt.Helpers; using LetsEncrypt.Helpers;
@ -32,7 +35,7 @@ namespace LetsEncrypt
} }
public void Run() { public void Run() {
_appSettings.environments.Where(env => env.active).ToList().ForEach(env => { foreach(var env in _appSettings.environments.Where(env => env.active)) {
try { try {
Console.WriteLine(string.Format("Let's Encrypt C# .Net Core Client, environment: {0}", env.name)); Console.WriteLine(string.Format("Let's Encrypt C# .Net Core Client, environment: {0}", env.name));
@ -189,10 +192,9 @@ namespace LetsEncrypt
} }
catch (Exception ex) { catch (Exception ex) {
Console.WriteLine(ex.Message.ToString()); Console.WriteLine(ex.Message.ToString());
break;
} }
}); }
} }
} }
} }

View File

@ -1,10 +1,12 @@
// https://tools.ietf.org/html/rfc7517
using System; using System;
using Newtonsoft.Json; using Newtonsoft.Json;
namespace LetsEncrypt.Entities namespace LetsEncrypt.Entities
{ {
public class Jwk public class Jwk
{ {
/// <summary> /// <summary>
/// "kty" (Key Type) Parameter /// "kty" (Key Type) Parameter

View File

@ -1,4 +1,9 @@
using System; /**
* https://tools.ietf.org/html/rfc4648
* https://tools.ietf.org/html/rfc4648#section-5
*/
using System;
using System.Security.Cryptography; using System.Security.Cryptography;
using System.Text; using System.Text;
using Newtonsoft.Json; using Newtonsoft.Json;
@ -31,8 +36,7 @@ namespace LetsEncrypt.Services
var publicParameters = rsa.ExportParameters(false); var publicParameters = rsa.ExportParameters(false);
_jwk = new Jwk _jwk = new Jwk () {
{
KeyType = "RSA", KeyType = "RSA",
Exponent = Base64UrlEncoded(publicParameters.Exponent), Exponent = Base64UrlEncoded(publicParameters.Exponent),
Modulus = Base64UrlEncoded(publicParameters.Modulus), Modulus = Base64UrlEncoded(publicParameters.Modulus),
@ -112,6 +116,7 @@ namespace LetsEncrypt.Services
return Base64UrlEncoded(Encoding.UTF8.GetBytes(s)); return Base64UrlEncoded(Encoding.UTF8.GetBytes(s));
} }
// https://tools.ietf.org/html/rfc4648#section-5
public string Base64UrlEncoded(byte[] arg) public string Base64UrlEncoded(byte[] arg)
{ {
var s = Convert.ToBase64String(arg); // Regular base64 encoder var s = Convert.ToBase64String(arg); // Regular base64 encoder

View File

@ -1,5 +1,4 @@
/** /**
* tools.itef.org/html/draft-itef-acme-acme-18
* https://community.letsencrypt.org/t/trying-to-do-post-as-get-but-getting-post-jws-not-signed/108371 * https://community.letsencrypt.org/t/trying-to-do-post-as-get-but-getting-post-jws-not-signed/108371
* https://tools.ietf.org/html/rfc8555#section-6.2 * https://tools.ietf.org/html/rfc8555#section-6.2
* *
@ -100,7 +99,6 @@ namespace LetsEncrypt.Services {
// 1 - Get directory // 1 - Get directory
(_directory, _) = await SendAsync<AcmeDirectory>(HttpMethod.Get, new Uri("directory", UriKind.Relative), null, token); (_directory, _) = await SendAsync<AcmeDirectory>(HttpMethod.Get, new Uri("directory", UriKind.Relative), null, token);
if (File.Exists(_path)) if (File.Exists(_path))
{ {
bool success; bool success;
@ -420,8 +418,7 @@ namespace LetsEncrypt.Services {
/// </summary> /// </summary>
/// <param name="token"></param> /// <param name="token"></param>
/// <returns></returns> /// <returns></returns>
public async Task KeyChange(CancellationToken token = default(CancellationToken)) public async Task KeyChange(CancellationToken token = default(CancellationToken)) {
{
} }
@ -431,8 +428,7 @@ namespace LetsEncrypt.Services {
/// </summary> /// </summary>
/// <param name="token"></param> /// <param name="token"></param>
/// <returns></returns> /// <returns></returns>
public async Task RevokeCertificate(CancellationToken token = default(CancellationToken)) public async Task RevokeCertificate(CancellationToken token = default(CancellationToken)) {
{
} }