Topic: Setting the valid date range when signing a cert
Hello,
Here is some background:
We are using our own internal CA. And we need a device to generate and sign a certificate using the CA.
I have all this working fine. Modeling off of OpenSSL is how I started.
However OpenSSL uses a CNF file for those settings. No such option appears to exist.
I did find this:
https://wolfssl.com/doxygen/group__ASN. … 130e2c6563
WOLFSSL_API int wc_SetDatesBuffer (Cert *, const byte * , int )
Which is one of the more useless explainations of how to function is used I've come across.
The example code is:
Cert myCert;
// initialize myCert
byte* der;
der = (byte*)malloc(FOURK_BUF);
// initialize der
if(wc_SetDatesBuffer(&myCert, der, FOURK_BUF) != 0) {
// error setting subject
}
Which only tells me I need a DER to use as a source for the dates... Kind of a "circular" goal...
Functionally, this all works, except the date is bad (dec 1969 as expected)
I need to be able to control the issue date and duration.
The (simplified) steps are:
wc_MakeRsaKey()
...
wc_InitCert(&testcert);
strcpy(testcert.subject.country, "US");
strcpy(testcert.subject.state, "IL");
... // Yeah, a request is created, all fields good, and ready to be signed...
caCertLength = LoadCACert(); // Load the CA from storage
wc_SetIssuerBuffer(testcert,m_caCert, caCertLength);
???
certsize = wc_MakeCert(&testcert, dercert, 4096, &genKey, NULL, &rng);
caKeyLength = LoadCAKey(); // Load the private key from storage
result = wc_RsaPrivateKeyDecode((const byte *)m_caKey, &idx, &cakey, caKeyLength);
????
certsize = wc_SignCert(testcert.bodySz, testcert.sigType, dercert, 4096, &cakey, NULL, &rng);
I am suspecting somewhere after "wc_SetIssueBuffer" or just before "wc_SignCert" is where the issue date and expiration date are set.
But there are no examples or explanations.
Can someone advise?
Thanks.
<Code shown is not to scale>