]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Generate a random serial number for 'tls ephemeral' certificates
authorAram Sargsyan <aram@isc.org>
Fri, 7 Jan 2022 20:32:18 +0000 (20:32 +0000)
committerAram Sargsyan <aram@isc.org>
Thu, 13 Jan 2022 11:03:07 +0000 (11:03 +0000)
Clients can cache the TLS certificates and refuse to accept
another one with the same serial number from the same issuer.

Generate a random serial number for the self-signed certificates
instead of using a fixed value.

lib/isc/tls.c

index cb8d41beb7b364da77ca68845c033950708449d7..35b8a1277e5e34d706c5d4c3b4ce0045dd017de5 100644 (file)
@@ -36,6 +36,7 @@
 #include <isc/mutex.h>
 #include <isc/mutexblock.h>
 #include <isc/once.h>
+#include <isc/random.h>
 #include <isc/refcount.h>
 #include <isc/rwlock.h>
 #include <isc/thread.h>
@@ -389,7 +390,9 @@ isc_tlsctx_createserver(const char *keyfile, const char *certfile,
                if (cert == NULL) {
                        goto ssl_error;
                }
-               ASN1_INTEGER_set(X509_get_serialNumber(cert), 1);
+
+               ASN1_INTEGER_set(X509_get_serialNumber(cert),
+                                (long)isc_random32());
 
 #if OPENSSL_VERSION_NUMBER < 0x10101000L
                X509_gmtime_adj(X509_get_notBefore(cert), 0);