You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm not quite sure what's going on here, but sometimes I can generate a self-signed x509 certificate that node's TLSSocket rejects with an ERR_OSSL_ASN1_ILLEGAL_PADDING error.
I think it's related to the serial number field, some values seem to not work
Here's a reproduction. The serial numbers from above cause new TLSSocket to throw Error: error:068000DD:asn1 encoding routines::illegal padding, the default serial number of "01" does not.
import*asx509from'@peculiar/x509'import{Crypto}from'@peculiar/webcrypto'import{Socket}from'net'import{TLSSocket}from'tls'constcrypto=newCrypto()x509.cryptoProvider.set(crypto)constkeys=awaitcrypto.subtle.generateKey({name: 'ECDSA',namedCurve: 'P-256',},true,['sign'])constcert=awaitx509.X509CertificateGenerator.createSelfSigned({// will throwserialNumber: '80048117884272',// does not throw//serialNumber: '01',// ...other certificate parametersname: 'CN=Test, O=Дом',notBefore: newDate('2020/01/01'),notAfter: newDate('2020/01/02'),signingAlgorithm: {name: 'ECDSA',hash: 'SHA-256',},keys: keys})// throws with certain serial numbersnewTLSSocket(newSocket(),{cert: cert.toString(),key: awaitprivateKeyToPEM(keys)})// helper to transform a private key to PEM formatasyncfunctionprivateKeyToPEM(keys){constarrayBuffer=awaitcrypto.subtle.exportKey('spki',keys.privateKey)letstr=Buffer.from(arrayBuffer).toString('base64')letfinalString='-----BEGIN PRIVATE KEY-----\n'while(str.length>0){finalString+=str.substring(0,64)+'\n'str=str.substring(64)}finalString=finalString+'-----END PRIVATE KEY-----'returnfinalString}
The text was updated successfully, but these errors were encountered:
This is a hack to work around PeculiarVentures/x509#74
until it is addressed upstream.
It seems serial numbers starting with `80` cause `@peculiar/x509` to
generate invalid certifiates that Node's `TLSSocket` then fails to
parse, throwing an `ERR_OSSL_ASN1_ILLEGAL_PADDING` error, so the hack
is to generate serial numbers until we get one that doesn't start with
`80`.
This can be reverted when the upstream issue is fixed.
This is a hack to work around PeculiarVentures/x509#74
until it is addressed upstream.
It seems serial numbers starting with `80` cause `@peculiar/x509` to
generate invalid certifiates that Node's `TLSSocket` then fails to
parse, throwing an `ERR_OSSL_ASN1_ILLEGAL_PADDING` error, so the hack
is to generate serial numbers until we get one that doesn't start with
`80`.
This can be reverted when the upstream issue is fixed.
I'm not quite sure what's going on here, but sometimes I can generate a self-signed x509 certificate that node's TLSSocket rejects with an
ERR_OSSL_ASN1_ILLEGAL_PADDING
error.I think it's related to the serial number field, some values seem to not work
Here are some example certificates:
Serial number
80048117884272
Serial number
80284629184668
Serial number
80290967596123
Serial number
8070459553297620
Weirdly they all begin with
80
, I don't know if that means anything or it's just a coincidence.Serial number
801234
Here's a reproduction. The serial numbers from above cause
new TLSSocket
to throwError: error:068000DD:asn1 encoding routines::illegal padding
, the default serial number of"01"
does not.The text was updated successfully, but these errors were encountered: