350350#define HAVE_STACK_OPENSSL_STRING_FUNCS OPENSSL_PREREQ(1,0,0)
351351#endif
352352
353+ #ifndef HAVE_X509_CRL_GET0_LASTUPDATE
354+ #define HAVE_X509_CRL_GET0_LASTUPDATE OPENSSL_PREREQ(1,1,0)
355+ #endif
356+
357+ #ifndef HAVE_X509_CRL_GET0_NEXTUPDATE
358+ #define HAVE_X509_CRL_GET0_NEXTUPDATE OPENSSL_PREREQ(1,1,0)
359+ #endif
360+
353361#ifndef HAVE_X509_GET_SIGNATURE_NID
354362#define HAVE_X509_GET_SIGNATURE_NID OPENSSL_PREREQ(1,0,2)
355363#endif
@@ -1753,6 +1761,14 @@ static int compat_SSL_CTX_set1_param(SSL_CTX *ctx, X509_VERIFY_PARAM *vpm) {
17531761#define X509_CRL_get0_ext (crt , i ) X509_CRL_get_ext((crt), (i))
17541762#endif
17551763
1764+ #if !HAVE_X509_CRL_GET0_LASTUPDATE
1765+ #define X509_CRL_get0_lastUpdate (crl ) ((const ASN1_TIME*)X509_CRL_get_lastUpdate(crl))
1766+ #endif
1767+
1768+ #if !HAVE_X509_CRL_GET0_NEXTUPDATE
1769+ #define X509_CRL_get0_nextUpdate (crl ) ((const ASN1_TIME*)X509_CRL_get_nextUpdate(crl))
1770+ #endif
1771+
17561772#if !HAVE_X509_EXTENSION_GET0_OBJECT
17571773#define X509_EXTENSION_get0_object (ext ) X509_EXTENSION_get_object((ext))
17581774#endif
@@ -5637,17 +5653,17 @@ static _Bool scan(int *i, char **cp, int n, int signok) {
56375653} /* scan() */
56385654
56395655
5640- static double timeutc (ASN1_TIME * time ) {
5656+ static double timeutc (const ASN1_TIME * time ) {
56415657 char buf [32 ] = "" , * cp ;
56425658 struct tm tm = { 0 };
56435659 int gmtoff = 0 , year , i ;
56445660
5645- if (!ASN1_TIME_check (time ))
5661+ if (!ASN1_TIME_check (( ASN1_STRING * ) time ))
56465662 return 0 ;
56475663
56485664 cp = strncpy (buf , (const char * )ASN1_STRING_get0_data ((ASN1_STRING * )time ), sizeof buf - 1 );
56495665
5650- if (ASN1_STRING_type (time ) == V_ASN1_GENERALIZEDTIME ) {
5666+ if (ASN1_STRING_type (( ASN1_STRING * ) time ) == V_ASN1_GENERALIZEDTIME ) {
56515667 if (!scan (& year , & cp , 4 , 1 ))
56525668 goto badfmt ;
56535669 } else {
@@ -5709,7 +5725,7 @@ static double timeutc(ASN1_TIME *time) {
57095725static int xc_getLifetime (lua_State * L ) {
57105726 X509 * crt = checksimple (L , 1 , X509_CERT_CLASS );
57115727 double begin = INFINITY , end = INFINITY ;
5712- ASN1_TIME * time ;
5728+ const ASN1_TIME * time ;
57135729
57145730 if ((time = X509_get_notBefore (crt )))
57155731 begin = timeutc (time );
@@ -6838,9 +6854,9 @@ static int xx_setVersion(lua_State *L) {
68386854static int xx_getLastUpdate (lua_State * L ) {
68396855 X509_CRL * crl = checksimple (L , 1 , X509_CRL_CLASS );
68406856 double updated = INFINITY ;
6841- ASN1_TIME * time ;
6857+ const ASN1_TIME * time ;
68426858
6843- if ((time = X509_CRL_get_lastUpdate (crl )))
6859+ if ((time = X509_CRL_get0_lastUpdate (crl )))
68446860 updated = timeutc (time );
68456861
68466862 if (isfinite (updated ))
@@ -6869,9 +6885,9 @@ static int xx_setLastUpdate(lua_State *L) {
68696885static int xx_getNextUpdate (lua_State * L ) {
68706886 X509_CRL * crl = checksimple (L , 1 , X509_CRL_CLASS );
68716887 double updateby = INFINITY ;
6872- ASN1_TIME * time ;
6888+ const ASN1_TIME * time ;
68736889
6874- if ((time = X509_CRL_get_nextUpdate (crl )))
6890+ if ((time = X509_CRL_get0_nextUpdate (crl )))
68756891 updateby = timeutc (time );
68766892
68776893 if (isfinite (updateby ))
@@ -6888,7 +6904,7 @@ static int xx_setNextUpdate(lua_State *L) {
68886904 double updateby = luaL_checknumber (L , 2 );
68896905 ASN1_TIME * time = NULL ;
68906906
6891- if (X509_CRL_get_nextUpdate (crl )) {
6907+ if (X509_CRL_get0_nextUpdate (crl )) {
68926908 if (!ASN1_TIME_set (X509_CRL_get_nextUpdate (crl ), updateby ))
68936909 goto error ;
68946910 } else {
0 commit comments