(bugfix): existing cert JswService missing initialization

This commit is contained in:
Maksym Sadovnychyy 2024-06-02 00:42:49 +02:00
parent 4359d317c0
commit 2b89c7e41d
2 changed files with 36 additions and 27 deletions

View File

@ -49,27 +49,6 @@
}, },
"response": [] "response": []
}, },
{
"name": "terms of service",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "http://localhost:8080/CertsFlow/TermsOfService/{{sessionId}}",
"protocol": "http",
"host": [
"localhost"
],
"port": "8080",
"path": [
"CertsFlow",
"TermsOfService",
"{{sessionId}}"
]
}
},
"response": []
},
{ {
"name": "configure client", "name": "configure client",
"event": [ "event": [
@ -130,6 +109,27 @@
}, },
"response": [] "response": []
}, },
{
"name": "terms of service",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "http://localhost:8080/CertsFlow/TermsOfService/{{sessionId}}",
"protocol": "http",
"host": [
"localhost"
],
"port": "8080",
"path": [
"CertsFlow",
"TermsOfService",
"{{sessionId}}"
]
}
},
"response": []
},
{ {
"name": "init", "name": "init",
"event": [ "event": [
@ -276,7 +276,7 @@
], ],
"body": { "body": {
"mode": "raw", "mode": "raw",
"raw": "{\r\n \"hostnames\": [\r\n \"maks-it.com\"\r\n ],\r\n \"challengeType\": \"http-01\"\r\n}", "raw": "{\r\n \"hostnames\": [\r\n \"staging.maks-it.com\"\r\n ],\r\n \"challengeType\": \"http-01\"\r\n}",
"options": { "options": {
"raw": { "raw": {
"language": "json" "language": "json"
@ -326,9 +326,10 @@
"method": "GET", "method": "GET",
"header": [], "header": [],
"url": { "url": {
"raw": "http://maks-it.com/.well-known/acme-challenge/{{challenge}}", "raw": "http://staging.maks-it.com/.well-known/acme-challenge/{{challenge}}",
"protocol": "http", "protocol": "http",
"host": [ "host": [
"staging",
"maks-it", "maks-it",
"com" "com"
], ],
@ -396,7 +397,7 @@
], ],
"body": { "body": {
"mode": "raw", "mode": "raw",
"raw": "{\r\n \"hostnames\": [\r\n \"maks-it.com\"\r\n ]\r\n}", "raw": "{\r\n \"hostnames\": [\r\n \"staging.maks-it.com\"\r\n ]\r\n}",
"options": { "options": {
"raw": { "raw": {
"language": "json" "language": "json"
@ -435,7 +436,7 @@
], ],
"body": { "body": {
"mode": "raw", "mode": "raw",
"raw": "{\r\n \"hostnames\": [\r\n \"maks-it.com\"\r\n ]\r\n}", "raw": "{\r\n \"hostnames\": [\r\n \"staging.maks-it.com\"\r\n ]\r\n}",
"options": { "options": {
"raw": { "raw": {
"language": "json" "language": "json"
@ -474,7 +475,7 @@
], ],
"body": { "body": {
"mode": "raw", "mode": "raw",
"raw": "{\r\n \"hostnames\": [\r\n \"maks-it.com\"\r\n ]\r\n}", "raw": "{\r\n \"hostnames\": [\r\n \"staging.maks-it.com\"\r\n ]\r\n}",
"options": { "options": {
"raw": { "raw": {
"language": "json" "language": "json"

View File

@ -12,6 +12,7 @@ using MaksIT.LetsEncrypt.Models.Requests;
using MaksIT.LetsEncrypt.Entities.Jws; using MaksIT.LetsEncrypt.Entities.Jws;
using DomainResults.Common; using DomainResults.Common;
using System.Net.Http.Headers; using System.Net.Http.Headers;
using System.Security.Principal;
namespace MaksIT.LetsEncrypt.Services; namespace MaksIT.LetsEncrypt.Services;
@ -100,10 +101,13 @@ public class LetsEncryptService : ILetsEncryptService {
if (cache != null && cache.AccountKey != null) { if (cache != null && cache.AccountKey != null) {
state.Cache = cache; state.Cache = cache;
accountKey.ImportCspBlob(cache.AccountKey); accountKey.ImportCspBlob(cache.AccountKey);
state.JwsService = new JwsService(accountKey);
state.JwsService.SetKeyId(cache.Location.ToString());
} }
else { else {
// New Account request // New Account request
state.JwsService = new JwsService(accountKey);
var letsEncryptOrder = new Account { var letsEncryptOrder = new Account {
TermsOfServiceAgreed = true, TermsOfServiceAgreed = true,
@ -111,6 +115,10 @@ public class LetsEncryptService : ILetsEncryptService {
}; };
var (account, postAccountResult) = await SendAsync<Account>(sessionId, HttpMethod.Post, state.Directory.NewAccount, false, letsEncryptOrder); var (account, postAccountResult) = await SendAsync<Account>(sessionId, HttpMethod.Post, state.Directory.NewAccount, false, letsEncryptOrder);
if (!postAccountResult.IsSuccess || account?.Result?.Location == null)
return postAccountResult;
state.JwsService = new JwsService(accountKey);
state.JwsService.SetKeyId(account.Result.Location.ToString()); state.JwsService.SetKeyId(account.Result.Location.ToString());
if (account.Result.Status != "valid") { if (account.Result.Status != "valid") {