I'm trying to figure out what these errors mean and what i am doing wrong
const out = JSON.stringify({csr: jose.base64url.encode(await generateCSRWithExistingKeys(subject, keyPair.publicKey, keyPair.privateKey))});
{"csr":"LS0tLS1CRUdJTiBDRVJUSUZJQ0FURSBSRVFVRVNULS0tLS0KTUlJQkx6Q0IxUUlCQURCaU1Ba0dBMVVFQmhNQ1ZWTXdFUVlEVlFRSUV3cERZV3hwWm05eWJtbGhNQlFHQTFVRQpCeE1OVTJGdUlFWnlZVzVqYVhOamJ6QWFCZ05WQkFvVEUwVjRZVzF3YkdVZ1EyOXljRzl5WVhScGIyNHdFQVlEClZRUURFd2x6YzJ3dVltOWhkSE13YWpBS0JnZ3Foa2pPUFFNQkJ3TmNBREJaTUJNR0J5cUdTTTQ5QWdFR0NDcUcKU000OUF3RUhBMElBQlB1VkJsOGhjSU95US9HenVOaDk2UlhEYUlaa2pZcDNUVkd2Qkc3YTZ2c3FSTnlnUEsvcwpweUptOE5MS2RXdHlwZG9xaWVWVzk2Yy9vNi81cHpTSXM2b3dBREFLQmdncWhrak9QUVFEQWdOSkFEQkdBaUVBCmd2clo4d3J5KzdGSStKVXVPMjUrOXdKYSt0WW1vNm1lQU5Jcm51Tnh0cmtDSVFERDZNS1lPa0Qwb0V2MFlzUVQKdUlBK29EdkJpL2t2dEsyVm93WURramVYUmc9PQotLS0tLUVORCBDRVJUSUZJQ0FURSBSRVFVRVNULS0tLS0"}
Error getting order {
type: 'urn:ietf:params:acme:error:malformed',
detail: "Error parsing certificate request: asn1: structure error: tags don't match (16 vs {class:0 tag:13 length:45 isCompound:true}) {optional:false explicit:false application:false private:false defaultValue:<nil> tag:<nil> stringType:0 timeType:0 set:false omitEmpty:false} certificateRequest @2"
Does this mean I shouldn't be calling jose.base64url.encode
or is there just something wrong with the CSR
?
const out = JSON.stringify({csr: await generateCSRWithExistingKeys(subject, keyPair.publicKey, keyPair.privateKey)});
{"csr":"-----BEGIN CERTIFICATE REQUEST-----\nMIIBLjCB1QIBADBiMAkGA1UEBhMCVVMwEQYDVQQIEwpDYWxpZm9ybmlhMBQGA1UE\nBxMNU2FuIEZyYW5jaXNjbzAaBgNVBAoTE0V4YW1wbGUgQ29ycG9yYXRpb24wEAYD\nVQQDEwlzc2wuYm9hdHMwajAKBggqhkjOPQMBBwNcADBZMBMGByqGSM49AgEGCCqG\nSM49AwEHA0IABPuVBl8hcIOyQ/GzuNh96RXDaIZkjYp3TVGvBG7a6vsqRNygPK/s\npyJm8NLKdWtypdoqieVW96c/o6/5pzSIs6owADAKBggqhkjOPQQDAgNIADBFAiEA\nji7UICP+mHi70eAgsjOufDLVlBuLQfjEFiSnrSP4hJcCIEKzOtclGdX0vvIb6DuX\nRmNPgX742pKHL2jL6Sy8eYIN\n-----END CERTIFICATE REQUEST-----"}
Error getting order {
type: 'urn:ietf:params:acme:error:malformed',
detail: 'Error unmarshaling finalize order request',
status: 400
}
If I don't encode the CSR
then I get a new error Error unmarshaling finalize order request
and i have no idea what that means even though I have looked around.
const subject = {
commonName: 'ssl.boats', // Lets Encrypt! only supports commonName @aarongable
};
const out = JSON.stringify({
csr: await generateCSRWithExistingKeys(subject, keyPair.publicKey, keyPair.privateKey)
});
const protectedHeader = {
alg: ALG_ECDSA,
kid: kid,
nonce: nonce,
url: finalizeUrl,
};
const jws = new jose.FlattenedSign(new TextEncoder().encode(out));
jws.setProtectedHeader(protectedHeader);
const signed = JSON.stringify(await jws.sign(keyPair.privateKey));
const request = {
method: 'POST',
headers: {
'Content-Type': CONTENT_TYPE_JOSE
},
body: signed
};
const response = await fetch(finalizeUrl, request);
If I do something like below I also get Error unmarshaling finalize order request
which makes me think encoding it was the correct thing to do...
const out = JSON.stringify({csr: { }});
If I do something like below I get Error parsing certificate request: asn1: syntax error: sequence truncated
, which makes me think encoding it would be wrong.
const out = JSON.stringify({csr: ""});
I'm just worried there is nothing wrong with the CSR
and I need to do something differently compared to the other things, any help would be appreciated, If you think it might be generateCSRWithExistingKeys
I can post that, but I'm wondering if its simpler than that.
Thanks everyone who helped.
If you want help and you understand Javascript
you can use server-ssl
as an example