Make OpenSSL accept expired certificates

前端 未结 2 1012
谎友^
谎友^ 2021-01-23 01:56

I\'m digging through the source code, trying to find a way to get OpenSSL to always accept expired certificates. I can\'t find the link between the expired errors/alarms and the

2条回答
  •  Happy的楠姐
    2021-01-23 02:16

    How I solved it:

    The time checks for certificates are in ssl/x509_vfy.c:

    static int check_cert_time(X509_STORE_CTX *ctx, X509 *x)
    {
        time_t *ptime;
        int i;
    
        .
        .
        .
    
        i = X509_cmp_time(X509_get_notAfter(x), ptime);
        .
        .
        .
    
        if (i < 0) {
            return 1;
            /* Allow expired certificates!
             *
             * ctx->error = X509_V_ERR_CERT_HAS_EXPIRED;
             * ctx->current_cert = x;
             * if (!ctx->verify_cb(0, ctx))
             *   return 0;
             */
        }
    
        return 1;
    }
    

    I just commented out part where is sets the expiration error. Not the best way to do it, I would suggest using jww's answer instead. I just thought I should document the solution I used.

    This solution means that openssl can't detect any expired certs, even if set_verify_cb changes the callback.

提交回复
热议问题