mirror of
https://github.com/status-im/nim-libp2p.git
synced 2025-02-28 04:20:39 +00:00
fix: add serial number to certificate
This commit is contained in:
parent
f87cc67130
commit
4f3651b63d
@ -374,6 +374,18 @@ proc generate*(
|
|||||||
# Set the MD algorithm
|
# Set the MD algorithm
|
||||||
mbedtls_x509write_crt_set_md_alg(addr crt, SIGNATURE_ALG)
|
mbedtls_x509write_crt_set_md_alg(addr crt, SIGNATURE_ALG)
|
||||||
|
|
||||||
|
# Generate a random serial number
|
||||||
|
const SERIAL_LEN = 20
|
||||||
|
var serialBuffer: array[SERIAL_LEN, byte]
|
||||||
|
ret = mbedtls_ctr_drbg_random(addr ctrDrbg, addr serialBuffer[0], SERIAL_LEN);
|
||||||
|
if ret != 0:
|
||||||
|
raise newException(CertificateCreationError, "Failed to generate serial number")
|
||||||
|
|
||||||
|
# Set the serial number
|
||||||
|
ret = mbedtls_x509write_crt_set_serial_raw(addr crt, addr serialBuffer[0], SERIAL_LEN);
|
||||||
|
if ret != 0:
|
||||||
|
raise newException(CertificateCreationError, "Failed to set serial number")
|
||||||
|
|
||||||
# Prepare Buffer for Certificate Serialization
|
# Prepare Buffer for Certificate Serialization
|
||||||
const CERT_BUFFER_SIZE = 4096
|
const CERT_BUFFER_SIZE = 4096
|
||||||
var
|
var
|
||||||
|
Loading…
x
Reference in New Issue
Block a user