src/ssl_sock.c
static int
smp_fetch_ssl_c_notafter(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
                       const struct arg *args, struct sample *smp)
{
	X509 *crt = NULL;
	int ret = 0;
	struct chunk *smp_trash;

	if (!l4 || l4->si[0].conn->xprt != &ssl_sock)
		return 0;

	if (!(l4->si[0].conn->flags & CO_FL_CONNECTED)) {
		smp->flags |= SMP_F_MAY_CHANGE;
		return 0;
	}

	/* SSL_get_peer_certificate, it increase X509 * ref count */
	crt = SSL_get_peer_certificate(l4->si[0].conn->xprt_ctx);
	if (!crt)
		goto out;

	smp_trash = get_trash_chunk();
	if (ssl_sock_get_time(X509_get_notAfter(crt), smp_trash) <= 0)
		goto out;

	smp->data.str = *smp_trash;
	smp->type = SMP_T_STR;
	ret = 1;
out:
	if (crt)
		X509_free(crt);
	return ret;
}
/*str, returns notafter date in ASN1_UTCTIME format */
str, returns notafter date in ASN1_UTCTIME format
str returns notafter date in ASN1_UTCTIME format
static int
smp_fetch_ssl_c_notafter(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
                       const struct arg *args, struct sample *smp)
{
	X509 *crt = NULL;
	int ret = 0;
	struct chunk *smp_trash;
	if (!l4 || l4->si[0].conn->xprt != &ssl_sock)
		return 0;
	if (!(l4->si[0].conn->flags & CO_FL_CONNECTED)) {
		smp->flags |= SMP_F_MAY_CHANGE;
		return 0;
	}
	crt = SSL_get_peer_certificate(l4->si[0].conn->xprt_ctx);
	if (!crt)
		goto out;
	smp_trash = get_trash_chunk();
	if (ssl_sock_get_time(X509_get_notAfter(crt), smp_trash) <= 0)
		goto out;
	smp->data.str = *smp_trash;
	smp->type = SMP_T_STR;
	ret = 1;
out:
	if (crt)
		X509_free(crt);
	return ret;
}
static int smp_fetch_ssl_c_notafter ( struct proxy * px , struct session * l4 , void * l7 , unsigned int opt , const struct arg * args , struct sample * smp ) { X509 * crt = NULL ; int ret = 0 ; struct chunk * smp_trash ; if ( ! l4 || l4 -> si [ 0 ] . conn -> xprt != & ssl_sock ) return 0 ; if ( ! ( l4 -> si [ 0 ] . conn -> flags & CO_FL_CONNECTED ) ) { smp -> flags |= SMP_F_MAY_CHANGE ; return 0 ; } crt = SSL_get_peer_certificate ( l4 -> si [ 0 ] . conn -> xprt_ctx ) ; if ( ! crt ) goto out ; smp_trash = get_trash_chunk ( ) ; if ( ssl_sock_get_time ( X509_get_notAfter ( crt ) , smp_trash ) <= 0 ) goto out ; smp -> data . str = * smp_trash ; smp -> type = SMP_T_STR ; ret = 1 ; out : if ( crt ) X509_free ( crt ) ; return ret ; }
str, returns notafter date in ASN1_UTCTIME format
str returns notafter date in ASN1_UTCTIME format
/* SSL_get_peer_certificate, it increase X509 * ref count */