Disable certificate notBefore/notAfter sanity check on OpenSSL < 1.0.2
PATCH 1/1 Disable certificate notBefore/notAfter sanity check on OpenSSL < 1.0.2
The SSL_CTX_get0_certificate() function I used in 091edd8e is available in OpenSSL 1.0.2+ only. Older versions seem to not have a useful alternative. The remaining option would then be to create a cache for our parsed certificate, but that would mean adding more struct members and code for the select group of people that do use an up-to-date openvpn, but do not update their openssl. I don't think that's worth it. So just disable the code for older openssl versions.
--- src/openvpn/ssl_openssl.c | 2 ++ 1 file changed, 2 insertions(+)
src/openvpn/ssl_openssl.c +2 -0
@@ -353,6 +353,7 @@ tls_ctx_restrict_ciphers(struct tls_root_ctx *ctx, const char *ciphers)void tls_ctx_check_cert_time (const struct tls_root_ctx *ctx) { +#if OPENSSL_VERSION_NUMBER >=0x10002000L int ret;const X509 *cert =SSL_CTX_get0_certificate (ctx->ctx);
@@ -375,6 +376,7 @@ tls_ctx_check_cert_time (const struct tls_root_ctx *ctx) {msg (M_WARN ,"WARNING: Your certificate has expired!" ); } +#endif }void
Signature · 1 line
2.5.0
ACK (grumble...)
Your patch has been applied to the master branch.
commit 644f2cdd13f49cd374aebc1fc506474104aac372
Author: Steffan Karger Date: Mon Dec 14 23:14:45 2015 +0100
Disable certificate notBefore/notAfter sanity check on OpenSSL < 1.0.2
Signed-off-by: Steffan Karger <[email protected]...>
Acked-by: Gert Doering <[email protected]...>
Message-Id: <[email protected]...>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10802
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
Hi,
Quoted 7 lines · Steffan Karger
The
SSL_CTX_get0_certificate()function I used in091edd8eis available in OpenSSL 1.0.2+ only. Older versions seem to not have a useful alternative. The remaining option would then be to create a cache for our parsed certificate, but that would mean adding more struct members and code for the select group of people that do use an up-to-date openvpn, but do not update their openssl. I don't think that's worth it. So just disable the code for older openssl versions.
I have code lying around for checking certificate dates for openssl v0.9.7+ ; you can find it here:
https://www.nikhef.nl/~janjust/proxy-verify/
the function of interest is grid_asn1TimeToTimeT ; it was/is on my TODO list to convert this code into a similar patch - perhaps we can integrate the two?
cheers,
JJK
Quoted 25 lines
Signed-off-by Steffan Karger <[email protected]...>--- src/openvpn/ssl_openssl.c | 2 ++ 1 file changed, 2 insertions(+)src/openvpn/ssl_openssl.c +2
-0@@ -353,6 +353,7 @@ tls_ctx_restrict_ciphers(struct tls_root_ctx *ctx, const char *ciphers)void tls_ctx_check_cert_time (const struct tls_root_ctx *ctx) { +#if OPENSSL_VERSION_NUMBER >=0x10002000L int ret;const X509 *cert =SSL_CTX_get0_certificate (ctx->ctx);@@ -375,6 +376,7 @@ tls_ctx_check_cert_time (const struct tls_root_ctx *ctx) {msg (M_WARN ,"WARNING: Your certificate has expired!" ); } +#endif }void
Hi,
Quoted 10 lines · Jan Just Keijser
Quoted 8 lines · Steffan Karger
The
SSL_CTX_get0_certificate()function I used in091edd8eis available in OpenSSL 1.0.2+ only. Older versions seem to not have a useful alternative.
The remaining option would then be to create a cache for our parsed certificate, but that would mean adding more struct members and code for the select group of people that do use an up-to-date openvpn, but do not update their openssl. I don't think that's worth it. So just disable the code for older openssl versions.
Quoted 7 lines
I have code lying around for checking certificate dates for openssl v0.9.7+ ; you can find it here:
https://www.nikhef.nl/~janjust/proxy-verify/the function of interest is
grid_asn1TimeToTimeT; it was/is on my TODO list to convert this code into a similar patch - perhaps we can integrate the two?
But before we extract the time from the certificate, we need to either cache our own x509 certificate (in the certificate file reading code, the pkcs11 code, the management-external-key code, the ms crapi code, etc...) or find a way to extract our own x509 cert from an SSL_CTX (which SSL_CTX_get0_certificate() does, since from that part of the code it *can* peek into the opaque 'struct cert_st').
Looking at the mess, I still think it is just not worth the extra code. But if you (or someone else) manage to find a clean and simple way to perform the check pre-1.0.2, I will gladly review a patch :)
-Steffan
Hi,
Quoted 26 lines · Steffan Karger
Hi,
Quoted 9 lines · Jan Just Keijser
Quoted 8 lines · Steffan Karger
The
SSL_CTX_get0_certificate()function I used in091edd8eis available in OpenSSL 1.0.2+ only. Older versions seem to not have a useful alternative.
The remaining option would then be to create a cache for our parsed certificate, but that would mean adding more struct members and code for the select group of people that do use an up-to-date openvpn, but do not update their openssl. I don't think that's worth it. So just disable the code for older openssl versions.Quoted 7 lines
I have code lying around for checking certificate dates for openssl v0.9.7+ ; you can find it here:
https://www.nikhef.nl/~janjust/proxy-verify/the function of interest is
grid_asn1TimeToTimeT; it was/is on my TODO list to convert this code into a similar patch - perhaps we can integrate the two?But before we extract the time from the certificate, we need to either cache our own x509 certificate (in the certificate file reading code, the pkcs11 code, the management-external-key code, the ms crapi code, etc...) or find a way to extract our own x509 cert from an
SSL_CTX(whichSSL_CTX_get0_certificate()does, since from that part of the code it *can* peek into the opaque 'structcert_st').
Quoted 4 lines
Looking at the mess, I still think it is just not worth the extra code. But if you (or someone else) manage to find a clean and simple way to perform the check pre-1.0.2, I will gladly review a patch :)
err, isn't it much easier to check the certificate expiry date when loading the cert, e.g. in "tls_ctx_load_cert_file_and_copy" in ssl_openssl.c ? or am I missing something here?
JJK
Quoted 28 lines
Quoted 28 lines
Quoted 16 lines
Quoted 10 lines
The
SSL_CTX_get0_certificate()function I used in091edd8eis available in
OpenSSL 1.0.2+ only. Older versions seem to not have a useful alternative.
The remaining option would then be to create a cache for our parsed certificate, but that would mean adding more struct members and code for the select group of people that do use an up-to-date openvpn, but do not update their openssl. I don't think that's worth it. So just disable the
code for older openssl versions.I have code lying around for checking certificate dates for openssl v0.9.7+
; you can find it here:
https://www.nikhef.nl/~janjust/proxy-verify/Quoted 4 lines
the function of interest is
grid_asn1TimeToTimeT; it was/is on my TODO list
to convert this code into a similar patch - perhaps we can integrate the two?But before we extract the time from the certificate, we need to either cache our own x509 certificate (in the certificate file reading code, the pkcs11 code, the management-external-key code, the ms crapi code, etc...) or find a way to extract our own x509 cert from an
SSL_CTX(whichSSL_CTX_get0_certificate()does, since from that part of the code it *can* peek into the opaque 'structcert_st').
Quoted 7 lines
Quoted 4 lines
Looking at the mess, I still think it is just not worth the extra code. But if you (or someone else) manage to find a clean and simple way to perform the check pre-1.0.2, I will gladly review a patch :)
err, isn't it much easier to check the certificate expiry date when loading the cert, e.g. in "
tls_ctx_load_cert_file_and_copy" inssl_openssl.c? or am I missing something here?
Yes, we could do that. But we would have to do that for both crypto libraries separately, and at each place where we load certificates (same list as above; file, pkcs#11, ms crapi, management-external-cert, maybe more?). Not as nice as a single check after all certificate processing.
-Steffan
Hi,
Quoted 30 lines · Steffan Karger
Quoted 30 lines
Quoted 30 lines
Quoted 15 lines
Quoted 10 lines
The
SSL_CTX_get0_certificate()function I used in091edd8eis available in
OpenSSL 1.0.2+ only. Older versions seem to not have a useful alternative.
The remaining option would then be to create a cache for our parsed certificate, but that would mean adding more struct members and code for the select group of people that do use an up-to-date openvpn, but do not update their openssl. I don't think that's worth it. So just disable the
code for older openssl versions.I have code lying around for checking certificate dates for openssl v0.9.7+
; you can find it here:
https://www.nikhef.nl/~janjust/proxy-verify/Quoted 4 lines
the function of interest is
grid_asn1TimeToTimeT; it was/is on my TODO list
to convert this code into a similar patch - perhaps we can integrate the two?But before we extract the time from the certificate, we need to either cache our own x509 certificate (in the certificate file reading code, the pkcs11 code, the management-external-key code, the ms crapi code, etc...) or find a way to extract our own x509 cert from an
SSL_CTX(whichSSL_CTX_get0_certificate()does, since from that part of the code it *can* peek into the opaque 'structcert_st').Looking at the mess, I still think it is just not worth the extra code. But if you (or someone else) manage to find a clean and simple way to perform the check pre-1.0.2, I will gladly review a patch :)
Quoted 10 lines
Quoted 3 lines
err, isn't it much easier to check the certificate expiry date when loading the cert, e.g. in "
tls_ctx_load_cert_file_and_copy" inssl_openssl.c? or am I missing something here?Yes, we could do that. But we would have to do that for both crypto libraries separately, and at each place where we load certificates (same list as above; file, pkcs#11, ms crapi, management-external-cert, maybe more?). Not as nice as a single check after all certificate processing.
ah well, in that case I would simply write out get0_certificate again: the code for that function actually is:
3011 X509 *SSL_CTX_get0_certificate(const SSL_CTX *ctx) 3012 {
3013 if (ctx->cert != NULL)
3014 return ctx->cert->key->x509;
3015 else
3016 return NULL;
3017 }
and as far as I can tell that "struct-path" is also valid for openssl < 1.0.2
cheers,
JJK
Hi,
Quoted 12 lines · Jan Just Keijser
ah well, in that case I would simply write out
get0_certificateagain: the code for that function actually is:3011 X509 *SSL_CTX_get0_certificate(const
SSL_CTX*ctx) 3012 {
3013 if (ctx->cert!= NULL)
3014 returnctx->cert->key->x509;
3015 else
3016 return NULL;
3017 }
Quoted 2 lines
and as far as I can tell that "struct-path" is also valid for openssl < 1.0.2
Yes that was my first attempt to work around it, but ctx->cert is an opaque struct cert_st (declared in ssl.h, but defined in ssl_locl.h, which is not in include/openssl/).
-Steffan