Skip to content

Commit 62bb9fc

Browse files
Fix openssl 1.1 deprecation X509_get_notBefore() and X509_get_notAfter() and make ssl_printtime() parameter const
1 parent 651b434 commit 62bb9fc

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/tls.c

+14-1
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,7 @@ static char *ssl_printname(X509_NAME *name)
593593
*
594594
* You need to nfree() the returned pointer.
595595
*/
596-
static char *ssl_printtime(ASN1_UTCTIME *t)
596+
static char *ssl_printtime(const ASN1_UTCTIME *t)
597597
{
598598
long len;
599599
char *data, *buf;
@@ -691,8 +691,13 @@ static void ssl_showcert(X509 *cert, const int loglev)
691691

692692

693693
/* Validity time */
694+
#if OPENSSL_VERSION_NUMBER >= 0x10100000L /* 1.1.0 */
695+
from = ssl_printtime(X509_get0_notBefore(cert));
696+
to = ssl_printtime(X509_get0_notAfter(cert));
697+
#else
694698
from = ssl_printtime(X509_get_notBefore(cert));
695699
to = ssl_printtime(X509_get_notAfter(cert));
700+
#endif
696701
putlog(loglev, "*", "TLS: certificate valid from %s to %s", from, to);
697702
nfree(from);
698703
nfree(to);
@@ -1113,11 +1118,19 @@ static int tcl_tlsstatus STDVAR
11131118
Tcl_DStringAppendElement(&ds, "issuer");
11141119
Tcl_DStringAppendElement(&ds, p);
11151120
nfree(p);
1121+
#if OPENSSL_VERSION_NUMBER >= 0x10100000L /* 1.1.0 */
1122+
p = ssl_printtime(X509_get0_notBefore(cert));
1123+
#else
11161124
p = ssl_printtime(X509_get_notBefore(cert));
1125+
#endif
11171126
Tcl_DStringAppendElement(&ds, "notBefore");
11181127
Tcl_DStringAppendElement(&ds, p);
11191128
nfree(p);
1129+
#if OPENSSL_VERSION_NUMBER >= 0x10100000L /* 1.1.0 */
1130+
p = ssl_printtime(X509_get0_notAfter(cert));
1131+
#else
11201132
p = ssl_printtime(X509_get_notAfter(cert));
1133+
#endif
11211134
Tcl_DStringAppendElement(&ds, "notAfter");
11221135
Tcl_DStringAppendElement(&ds, p);
11231136
nfree(p);

0 commit comments

Comments
 (0)