@@ -151,7 +151,7 @@ static int gen_key(SSLCert &certCtx, SSLKeySize keySize) {
151
151
*
152
152
* Based on programs/x509/cert_write.c
153
153
*/
154
- static int cert_write (SSLCert &certCtx, std::string dn) {
154
+ static int cert_write (SSLCert &certCtx, std::string dn, std::string validityFrom, std::string validityTo ) {
155
155
int funcRes = 0 ;
156
156
int stepRes = 0 ;
157
157
@@ -210,7 +210,7 @@ static int cert_write(SSLCert &certCtx, std::string dn) {
210
210
}
211
211
212
212
// Set the validity of the c
10000
ertificate. At the moment, it's fixed from 2019 to end of 2029.
213
- stepRes = mbedtls_x509write_crt_set_validity ( &crt, " 20190101000000 " , " 20300101000000 " );
213
+ stepRes = mbedtls_x509write_crt_set_validity ( &crt, validityFrom. c_str (), validityTo. c_str () );
214
214
if (stepRes != 0 ) {
215
215
funcRes = HTTPS_SERVER_ERROR_CERTGEN_VALIDITY;
216
216
goto error_after_cert;
@@ -284,8 +284,8 @@ static int cert_write(SSLCert &certCtx, std::string dn) {
284
284
return funcRes;
285
285
}
286
286
287
- int createSelfSignedCert (SSLCert &certCtx, SSLKeySize keySize, std::string dn) {
288
-
287
+ int createSelfSignedCert (SSLCert &certCtx, SSLKeySize keySize, std::string dn, std::string validFrom, std::string validUntil ) {
288
+
289
289
// Add the private key
290
290
int keyRes = gen_key (certCtx, keySize);
291
291
if (keyRes != 0 ) {
@@ -294,7 +294,7 @@ int createSelfSignedCert(SSLCert &certCtx, SSLKeySize keySize, std::string dn) {
294
294
}
295
295
296
296
// Add the self-signed certificate
297
- int certRes = cert_write (certCtx, dn);
297
+ int certRes = cert_write (certCtx, dn, validFrom, validUntil );
298
298
if (certRes != 0 ) {
299
299
// Cert writing failed, reset the pk and return failure code
300
300
certCtx.setPK (NULL , 0 );
0 commit comments