Extend verify-hash to allow multiple hashes
PATCH v2 1/5 Extend verify-hash to allow multiple hashes
This patch introduces support for verify-hash inlining.
When inlined, this options now allows to specify multiple fingerprints, one per line.
Since this is a new syntax, there is no backwards compatibility to take care of, therefore we can drop support for SHA1. Inlined fingerprints are assumed be to SHA-256 only.
Also print a warning about SHA1 hash being deprecated to verify certificates as it is not "industry standard" anymore.
Patch v2: fix/clarify various comments, fix a few minor problems, allow
the option to be specified multiple times and have that added to the list.
--- doc/man-sections/inline-files.rst | 4 +- doc/man-sections/tls-options.rst | 10 +++ src/openvpn/options.c | 107 +++++++++++++++++++++++++++--- src/openvpn/options.h | 10 ++- src/openvpn/ssl_common.h | 2 +- src/openvpn/ssl_verify.c | 17 ++++- 6 files changed, 133 insertions(+), 17 deletions(-)
doc/man-sections/inline-files.rst +2 -2
@@ -4,8 +4,8 @@ INLINE FILE SUPPORT OpenVPN allows including files in the main configuration for the ``--ca``, ``--cert``, ``--dh``, ``--extra-certs``, ``--key``, ``--pkcs12``, ``--secret``, ``--crl-verify``, ``--http-proxy-user-pass``, ``--tls-auth``, -``--auth-gen-token-secret``, ``--tls-crypt`` and ``--tls-crypt-v2`` -options. +``--auth-gen-token-secret``, ``--tls-crypt``, ``--tls-crypt-v2`` and +``--verify-hash`` options. Each inline file started by the line ``<option>`` and ended by the line ``</option>``
doc/man-sections/tls-options.rst +10 -0
@@ -582,6 +582,16 @@ certificates and keys: https://github.com/OpenVPN/easy-rsa The ``algo`` flag can be either :code:`SHA1` or :code:`SHA256`. If not provided, it defaults to :code:`SHA1`. + This option can also be inlined + :: + + <verify-hash> + 00:11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff:00:11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff + 11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff:00:11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff:00 + </verify-hash> + +If the option is inlined, ``algo`` is always :code:`SHA256`. + --verify-x509-name args Accept connections only if a host's X.509 name is equal to **name.** The remote host must also pass all other tests of verification.
src/openvpn/options.c +96 -11
147 lines not on this page · raw message
src/openvpn/options.h +9 -1
@@ -191,6 +191,14 @@ enum genkey_type {GENKEY_AUTH_TOKEN }; +struct verify_hash_list +{ +/* We support SHA256 and SHA1 fingerpint. In the case of using the +* deprecated SHA1, only the first 20 bytes of each list item are used */ +uint8_t hash[SHA256_DIGEST_LENGTH ]; +struct verify_hash_list *next; +}; +/* Command line options */ struct options {
@@ -550,7 +558,7 @@ struct optionsint ns_cert_type;/* set to 0, NS_CERT_CHECK_SERVER, or NS_CERT_CHECK_CLIENT */ unsigned remote_cert_ku[MAX_PARMS ];const char *remote_cert_eku; -uint8_t *verify_hash; +struct verify_hash_list *verify_hash;hash_algo_type verify_hash_algo;unsigned int ssl_flags;/* set to SSLF_x flags from ssl.h */
src/openvpn/ssl_common.h +1 -1
@@ -283,7 +283,7 @@ struct tls_optionsint ns_cert_type;unsigned remote_cert_ku[MAX_PARMS ];const char *remote_cert_eku; -uint8_t *verify_hash; +struct verify_hash_list *verify_hash;hash_algo_type verify_hash_algo;#ifdef ENABLE_X509ALTUSERNAME char *x509_username_field[MAX_PARMS ];
src/openvpn/ssl_verify.c +15 -2
@@ -748,9 +748,22 @@ verify_cert(struct tls_session *session, openvpn_x509_cert_t *cert, int cert_dep goto cleanup; } -if (memcmp (BPTR (&ca_hash), opt->verify_hash,BLEN (&ca_hash))) +struct verify_hash_list *current_hash = opt->verify_hash; + +while (current_hash) + { +if (memcmp_constant_time (BPTR (&ca_hash), current_hash->hash, +BLEN (&ca_hash)) ==0 ) + { + hash_matched = true; +break ; + } + current_hash = current_hash->next; + } + +if (!current_hash) { -msg (D_TLS_ERRORS ,"TLS Error: level-1 certificate hash verification failed" ); +msg (D_TLS_ERRORS ,"TLS Error: --tls-verify certificate hash verification failed" ); goto cleanup; } }
Signature · 1 line
2.30.1
PATCH v2 2/5 Implement peer-fingerprint to check fingerprint of peer certificate
This option allows to pin one or more more peer certificates. It also prepares for doing TLS authentication without a CA and just self-signed certificates.
Patch V2: Allow peer-fingerprint to be specified multiple times
to allow multiple peers without needing to use inline syntax. (e.g. on command line).
--- Changes.rst | 9 ++++++- doc/man-sections/inline-files.rst | 4 +-- doc/man-sections/tls-options.rst | 22 +++++++++++++++- src/openvpn/init.c | 1 + src/openvpn/options.c | 43 ++++++++++++++++++++++++------- src/openvpn/options.h | 1 + src/openvpn/ssl_common.h | 1 + src/openvpn/ssl_verify.c | 19 ++++++++------ 8 files changed, 78 insertions(+), 22 deletions(-)
Changes.rst +8 -1
@@ -22,13 +22,20 @@ Compatibility with OpenSSL in FIPS mode Deprecated features ------------------- -``inetd`` has been removed +``inetd`` has been removed This was a very limited and not-well-tested way to run OpenVPN, on TCP and TAP mode only. Overview of changes in 2.5 ========================== +New features in 2.5.1 +--------------------- +Certificate pinning/verify peer fingerprint + The ``--peer-fingerprint`` option has been introduced to give users an + easy to use alternative to the ``tls-verify`` for matching the + fingerprint of the peer. The option takes use a number of allowed + SHA256 certificate fingerprints. New features ------------
doc/man-sections/inline-files.rst +2 -2
@@ -4,8 +4,8 @@ INLINE FILE SUPPORT OpenVPN allows including files in the main configuration for the ``--ca``, ``--cert``, ``--dh``, ``--extra-certs``, ``--key``, ``--pkcs12``, ``--secret``, ``--crl-verify``, ``--http-proxy-user-pass``, ``--tls-auth``, -``--auth-gen-token-secret``, ``--tls-crypt``, ``--tls-crypt-v2`` and -``--verify-hash`` options. +``--auth-gen-token-secret``, ``--peer-fingerprint``, ``--tls-crypt``, +``--tls-crypt-v2`` and ``--verify-hash`` options. Each inline file started by the line ``<option>`` and ended by the line ``</option>``
doc/man-sections/tls-options.rst +21 -1
@@ -271,7 +271,8 @@ certificates and keys: https://github.com/OpenVPN/easy-rsa man-in-the-middle attack where an authorized client attempts to connect to another client by impersonating the server. The attack is easily prevented by having clients verify the server certificate using any one - of ``--remote-cert-tls``, ``--verify-x509-name``, or ``--tls-verify``. + of ``--remote-cert-tls``, ``--verify-x509-name``, ``--peer-fingerprint`` + or ``--tls-verify``. --tls-auth args Add an additional layer of HMAC authentication on top of the TLS control
@@ -592,6 +593,25 @@ certificates and keys: https://github.com/OpenVPN/easy-rsa If the option is inlined, ``algo`` is always :code:`SHA256`. +--peer-fingerprint args + Specify a SHA256 fingerprint or list of SHA256 fingerprints to verify + the peer certificate against. The peer certificate must match one of the + fingerprint or certificate verification will fail. The option can also + be inlined + + Valid syntax: + :: + + peer-fingerprint AD:B0:95:D8:09:... + + or inline: + :: + + <peer-fingerprint> + 00:11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff:00:11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff + 11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff:00:11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff:00 + </peer-fingerprint> + --verify-x509-name args Accept connections only if a host's X.509 name is equal to **name.** The remote host must also pass all other tests of verification.
src/openvpn/init.c +1 -0
@@ -2927,6 +2927,7 @@ do_init_crypto_tls(struct context *c, const unsigned int flags) to.remote_cert_eku = options->remote_cert_eku; to.verify_hash = options->verify_hash; to.verify_hash_algo = options->verify_hash_algo; + to.verify_hash_depth = options->verify_hash_depth;#ifdef ENABLE_X509ALTUSERNAME memcpy (to.x509_username_field, options->x509_username_field,sizeof (to.x509_username_field));#else
src/openvpn/options.c +33 -10
64 lines not on this page · raw message
src/openvpn/options.h +1 -0
@@ -560,6 +560,7 @@ struct optionsconst char *remote_cert_eku;struct verify_hash_list *verify_hash;hash_algo_type verify_hash_algo; +int verify_hash_depth;unsigned int ssl_flags;/* set to SSLF_x flags from ssl.h */ #ifdef ENABLE_PKCS11
src/openvpn/ssl_common.h +1 -0
@@ -284,6 +284,7 @@ struct tls_optionsunsigned remote_cert_ku[MAX_PARMS ];const char *remote_cert_eku;struct verify_hash_list *verify_hash; +int verify_hash_depth;hash_algo_type verify_hash_algo;#ifdef ENABLE_X509ALTUSERNAME char *x509_username_field[MAX_PARMS ];
src/openvpn/ssl_verify.c +11 -8
@@ -721,19 +721,18 @@ verify_cert(struct tls_session *session, openvpn_x509_cert_t *cert, int cert_dep goto cleanup;/* Reject connection */ } -/* verify level 1 cert, i.e. the CA that signed our leaf cert */ -if (cert_depth ==1 && opt->verify_hash) +if (cert_depth == opt->verify_hash_depth && opt->verify_hash) { -struct buffer ca_hash = {0 }; +struct buffer cert_fp = {0 };switch (opt->verify_hash_algo) {case MD_SHA1 : - ca_hash =x509_get_sha1_fingerprint (cert, &gc); + cert_fp =x509_get_sha1_fingerprint (cert, &gc);break ;case MD_SHA256 : - ca_hash =x509_get_sha256_fingerprint (cert, &gc); + cert_fp =x509_get_sha256_fingerprint (cert, &gc);break ;default :
@@ -752,8 +751,8 @@ verify_cert(struct tls_session *session, openvpn_x509_cert_t *cert, int cert_depwhile (current_hash) { -if (memcmp_constant_time (BPTR (&ca_hash), current_hash->hash, -BLEN (&ca_hash)) ==0 ) +if (memcmp_constant_time (BPTR (&cert_fp), current_hash->hash, +BLEN (&cert_fp)) ==0 ) { hash_matched = true;break ;
@@ -763,7 +762,11 @@ verify_cert(struct tls_session *session, openvpn_x509_cert_t *cert, int cert_depif (!current_hash) { -msg (D_TLS_ERRORS ,"TLS Error: --tls-verify certificate hash verification failed" ); +const char *hex_fp =format_hex_ex (BPTR (&cert_fp),BLEN (&cert_fp), +0 ,1 ,":" , &gc); +msg (D_TLS_ERRORS ,"TLS Error: --tls-verify/--peer-fingerprint" +"certificate hash verification failed. (got " +"fingerprint: %s" , hex_fp); goto cleanup; } }
Signature · 1 line
2.30.1
PATCH v2 3/5 Support fingerprint authentication without CA certificate
In reply to Arne SchwabeFrom: "Jason A. Donenfeld" <[email protected]...>
OpenVPN traditionally works around CAs. However many TLS-based protocols also allow an alternative simpler mode in which rather than verify certificates against CAs, the certificate itself is hashed and compared against a pre-known set of acceptable hashes. This is usually referred to as "fingerprint verification". It's popular across SMTP servers, IRC servers, XMPP servers, and even in the context of HTTP with pinning.
* Allow not specifying the --ca parameter, to specify that certificates should not be checked against a CA.
I've included some instructions on how to use all of this.
Server side:
============
Make self-signed cert:
$ openssl req -x509 -newkey ec:<(openssl ecparam -name secp384r1) -keyout serverkey.pem -out servercert.pem -nodes -sha256 -days 3650 -subj '/CN=server'
Record our fingerprint in an environment variable for the client to use later:
$ server_fingerprint="$(openssl x509 -in servercert.pem -noout -sha256 -fingerprint | sed 's/.*=//;s/\(.*\)/\1/')"
Client side:
============
Make self-signed cert:
$ openssl req -x509 -newkey ec:<(openssl ecparam -name secp384r1) -keyout clientkey.pem -out clientcert.pem -nodes -sha256 -days 3650 -subj '/CN=client'
Record our fingerprint in an environment variable for the server to use later:
$ client_fingerprint="$(openssl x509 -in clientcert.pem -noout -sha256 -fingerprint | sed 's/.*=//;s/\(.*\)/\1/')"
Start server/client
===================
Start openvpn with peer fingerprint verification:
$ sudo openvpn --server 10.66.0.0 255.255.255.0 --dev tun --dh none --cert servercert.pem --key serverkey.pem --peer-fingerprint "$client_fingerprint"
$ sudo openvpn --client --remote 127.0.0.1 --dev tun --cert clientcert.pem --key clientkey.pem --peer-fingerprint "$server_fingerprint" --nobind
Patch V2: Changes in V2 (by Arne Schwabe):
- Only check peer certificates, not all cert levels, if you need multiple levels of certificate you should use a real CA
- Use peer-fingerprint instead tls-verify on server side in example.
- rename variable ca_file_none to verify_hash_no_ca
- do no require --ca none but allow --ca simply
to be absent when --peer-fingprint is present
- adjust warnings/errors messages to also point to peer-fingerprint as valid verification method.
- Fix mbed TLS version of not requiring CA
not working
--- src/openvpn/init.c | 2 ++ src/openvpn/options.c | 30 +++++++++++++++++++++++------- src/openvpn/options.h | 1 + src/openvpn/ssl.c | 2 +- src/openvpn/ssl_common.h | 1 + src/openvpn/ssl_verify_mbedtls.c | 17 +++++++++++++++++ src/openvpn/ssl_verify_openssl.c | 2 +- 7 files changed, 46 insertions(+), 9 deletions(-)
src/openvpn/init.c +2 -0
@@ -2928,6 +2928,8 @@ do_init_crypto_tls(struct context *c, const unsigned int flags) to.verify_hash = options->verify_hash; to.verify_hash_algo = options->verify_hash_algo; to.verify_hash_depth = options->verify_hash_depth; + to.verify_hash_no_ca = options->verify_hash_no_ca; +#ifdef ENABLE_X509ALTUSERNAME memcpy (to.x509_username_field, options->x509_username_field,sizeof (to.x509_username_field));#else
src/openvpn/options.c +23 -7
@@ -2712,18 +2712,23 @@ options_postprocess_verify_ce(const struct options *options,else {#ifdef ENABLE_CRYPTO_MBEDTLS -if (!(options->ca_file)) +if (!(options->ca_file || options->verify_hash_no_ca)) { -msg (M_USAGE ,"You must define CA file (--ca)" ); +msg (M_USAGE ,"You must define CA file (--ca) and/or " +"peer fingeprint verification " +"(--peer-fingerprint)" ); }if (options->ca_path) {msg (M_USAGE ,"Parameter --capath cannot be used with the mbed TLS version version of OpenVPN." ); }#else /* ifdef ENABLE_CRYPTO_MBEDTLS */ -if ((!(options->ca_file)) && (!(options->ca_path))) +if ((!(options->ca_file)) && (!(options->ca_path)) + && (!(options->verify_hash_no_ca))) { -msg (M_USAGE ,"You must define CA file (--ca) or CA path (--capath)" ); +msg (M_USAGE ,"You must define CA file (--ca) or CA path " +"(--capath) and/or peer fingeprint verification " +"(--peer-fingerprint)" ); }#endif if (pull)
@@ -2742,7 +2747,8 @@ options_postprocess_verify_ce(const struct options *options,#if P2MP if (!options->auth_user_pass_file)#endif -msg (M_USAGE ,"No client-side authentication method is specified. You must use either --cert/--key, --pkcs12, or --auth-user-pass" ); +msg (M_USAGE ,"No client-side authentication method is specified. You must use either --cert/--key," +" --pkcs12, or --auth-user-pass" ); }else if (sum ==2 ) {
@@ -3206,6 +3212,13 @@ options_postprocess_mutate(struct options *o) options_postprocess_http_proxy_override(o); }#endif +if (!o->ca_file && !o->ca_path && o->verify_hash + && o->verify_hash_depth ==0 ) + { +msg (M_INFO ,"Using certificate fingerprint to verify peer (no CA " +"option set). " ); + o->verify_hash_no_ca = true; + }#if P2MP /*
@@ -3441,8 +3454,11 @@ options_postprocess_filechecks(struct options *options) errs |=check_file_access_inline (options->dh_file_inline,CHKACC_FILE , options->dh_file,R_OK ,"--dh" ); - errs |=check_file_access_inline (options->ca_file_inline,CHKACC_FILE , - options->ca_file,R_OK ,"--ca" ); +if (!options->verify_hash_no_ca) + { + errs |=check_file_access_inline (options->ca_file_inline,CHKACC_FILE , + options->ca_file,R_OK ,"--ca" ); + } errs |=check_file_access_chroot (options->chroot_dir,CHKACC_FILE , options->ca_path,R_OK ,"--capath" );
src/openvpn/options.h +1 -0
@@ -561,6 +561,7 @@ struct optionsstruct verify_hash_list *verify_hash;hash_algo_type verify_hash_algo;int verify_hash_depth; +bool verify_hash_no_ca;unsigned int ssl_flags;/* set to SSLF_x flags from ssl.h */ #ifdef ENABLE_PKCS11
src/openvpn/ssl.c +1 -1
@@ -682,7 +682,7 @@ init_ssl(const struct options *options, struct tls_root_ctx *new_ctx) }#endif -if (options->ca_file || options->ca_path) +if ((!options->verify_hash_no_ca && options->ca_file) || options->ca_path) {tls_ctx_load_ca (new_ctx, options->ca_file, options->ca_file_inline, options->ca_path, options->tls_server);
src/openvpn/ssl_common.h +1 -0
@@ -285,6 +285,7 @@ struct tls_optionsconst char *remote_cert_eku;struct verify_hash_list *verify_hash;int verify_hash_depth; +bool verify_hash_no_ca;hash_algo_type verify_hash_algo;#ifdef ENABLE_X509ALTUSERNAME char *x509_username_field[MAX_PARMS ];
src/openvpn/ssl_verify_mbedtls.c +17 -0
@@ -62,6 +62,23 @@ verify_callback(void *session_obj, mbedtls_x509_crt *cert, int cert_depth,struct buffer cert_fingerprint =x509_get_sha256_fingerprint (cert, &gc);cert_hash_remember (session, cert_depth, &cert_fingerprint); + +if (session->opt->verify_hash_no_ca) + { +/* +* If we decide to verify the peer certificate based on the fingerprint +* we ignore wrong dates and the certificate not being trusted. +* Any other problem with the certificate (wrong key, bad cert,...) +* will still trigger an error. +* Clearing these flags relies on verify_cert will later rejecting a +* certificate that has no matching fingerprint. +*/ +uint32_t flags_ignore =MBEDTLS_X509_BADCERT_NOT_TRUSTED + |MBEDTLS_X509_BADCERT_EXPIRED + |MBEDTLS_X509_BADCERT_FUTURE ; + *flags = *flags & ~flags_ignore; + } +/* did peer present cert which was signed by our root cert? */ if (*flags !=0 ) {
src/openvpn/ssl_verify_openssl.c +1 -1
@@ -67,7 +67,7 @@ verify_callback(int preverify_ok, X509_STORE_CTX *ctx)cert_hash_remember (session,X509_STORE_CTX_get_error_depth (ctx), &cert_hash);/* did peer present cert which was signed by our root cert? */ -if (!preverify_ok) +if (!preverify_ok && !session->opt->verify_hash_no_ca) {/* get the X509 name */ char *subject =x509_get_subject (current_cert, &gc);
Signature · 1 line
2.30.1
PATCH v2 5/5 Deprecate the --verify-hash option
In reply to Arne SchwabeDespite trying to figure out with multiple people what the use case for this option is, we could not come up with a good one. Checking that only a specific CA is used can be also done by only using that CA in the --ca directive.
Although it feels a bit strange to deprecate the option after improving it with peer-fingerprint patches, all the improvements are needed for --peer-fingerprint and making them specify to --peer-fingerprint would have added more (unecessary) changes.
--- Changes.rst | 3 +++ doc/man-sections/tls-options.rst | 2 +- src/openvpn/options.c | 6 +++--- 3 files changed, 7 insertions(+), 4 deletions(-)
Changes.rst +3 -0
@@ -26,6 +26,9 @@ Deprecated features This was a very limited and not-well-tested way to run OpenVPN, on TCP and TAP mode only. +``verify-hash`` has been deprecated + This option has very limited usefulness and should be replaced by either + a better ``--ca`` configuration or with a ``--tls-verify`` script. Overview of changes in 2.5 ==========================
doc/man-sections/tls-options.rst +1 -1
@@ -564,7 +564,7 @@ certificates and keys: https://github.com/OpenVPN/easy-rsa :code:`1.2`. --verify-hash args - Specify SHA1 or SHA256 fingerprint for level-1 cert. + **DEPRECATED** Specify SHA1 or SHA256 fingerprint for level-1 cert. Valid syntax: ::
src/openvpn/options.c +3 -3
@@ -8142,6 +8142,9 @@ add_option(struct options *options,int verify_hash_depth =0 ;if (streq (p[0 ],"verify-hash" )) { +"DEPRECATED OPTION: The option --verify-hash is deprecated. " +"You should switch to the either use the level 1 certificate as " +"--ca option, use --tls-verify or use --peer-fingerprint" ;/* verify level 1 cert, i.e. the CA that signed the leaf cert */ verify_hash_depth =1 ; }
@@ -8164,9 +8167,6 @@ add_option(struct options *options,if ((!p[2 ] && !is_inline) || (p[2 ] &&streq (p[2 ],"SHA1" ))) { options->verify_hash_algo =MD_SHA1 ; -msg (M_WARN ,"DEPRECATED FEATURE: Usage of SHA1 fingerprints for " -"verify-hash is deprecated. You should switch to the " -"SHA256." ); options->verify_hash_algo =SHA_DIGEST_LENGTH ; digest_len =SHA_DIGEST_LENGTH ; }
Signature · 1 line
2.30.1
Hi,
Quoted 178 lines · Arne Schwabe
This patch introduces support for verify-hash inlining.
When inlined, this options now allows to specify multiple fingerprints, one per line.Since this is a new syntax, there is no backwards compatibility to take care of, therefore we can drop support for SHA1. Inlined fingerprints are assumed be to SHA-256 only.
Also print a warning about SHA1 hash being deprecated to verify certificates as it is not "industry standard" anymore.
Patch v2: fix/clarify various comments, fix a few minor problems, allow
the option to be specified multiple times and have that added to the list.Signed-off-by Arne Schwabe <[email protected]...>--- doc/man-sections/inline-files.rst | 4 +- doc/man-sections/tls-options.rst | 10 +++ src/openvpn/options.c | 107 +++++++++++++++++++++++++++--- src/openvpn/options.h | 10 ++- src/openvpn/ssl_common.h | 2 +- src/openvpn/ssl_verify.c | 17 ++++- 6 files changed, 133 insertions(+), 17 deletions(-)doc/man-sections/inline-files.rst +2
-2@@ -4,8 +4,8 @@ INLINE FILE SUPPORT OpenVPN allows including files in the main configuration for the ``--ca``, ``--cert``, ``--dh``, ``--extra-certs``, ``--key``, ``--pkcs12``, ``--secret``, ``--crl-verify``, ``--http-proxy-user-pass``, ``--tls-auth``, -``--auth-gen-token-secret``, ``--tls-crypt`` and ``--tls-crypt-v2`` -options. +``--auth-gen-token-secret``, ``--tls-crypt``, ``--tls-crypt-v2`` and +``--verify-hash`` options. Each inline file started by the line ``<option>`` and ended by the line ``</option>``doc/man-sections/tls-options.rst +10
-0@@ -582,6 +582,16 @@ certificates and keys: https://github.com/OpenVPN/easy-rsa The ``algo`` flag can be either :code:`SHA1` or :code:`SHA256`. If not provided, it defaults to :code:`SHA1`. + This option can also be inlined + :: + + <verify-hash> + 00:11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff:00:11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff + 11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff:00:11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff:00 + </verify-hash> + +If the option is inlined, ``algo`` is always :code:`SHA256`. + --verify-x509-name args Accept connections only if a host's X.509 name is equal to **name.** The remote host must also pass all other tests of verification.src/openvpn/options.c +71
-6@@ -1078,12 +1078,24 @@ string_substitute(const char *src, int from, int to, struct gc_arena *gc)return ret; } -static uint8_t * +/** +* Parses a hexstring and checks if the string has the correct length. Return +* a verify_hash_list containing the parsed hash string. +* +* @param str String to check/parse +* @param nbytes Number of bytes expected in the hexstr (e.g. 20 for SHA1) +* @param msglevel message level to use when printing warnings/errors +* @param gc The returned object will be allocated in this gc +*/ +static struct verify_hash_list *parse_hash_fingerprint (const char *str,int nbytes,int msglevel,struct gc_arena *gc) {int i;const char *cp = str; -uint8_t *ret = (uint8_t *)gc_malloc (nbytes, true, gc); + +struct verify_hash_list *ret; + ALLOC_OBJ_CLEAR_GC(ret, struct verify_hash_list, gc); +char term =1 ;int byte;char bs[3 ];@@ -1102,7 +1114,7 @@ parse_hash_fingerprint(const char *str, int nbytes, int msglevel, struct gc_aren {msg (msglevel,"format error in hash fingerprint hex byte: %s" , str); } - ret[i] = (uint8_t )byte; + ret->hash[i] = (uint8_t )byte; term = *cp++;if (term !=':' && term !=0 ) {@@ -1116,10 +1128,55 @@ parse_hash_fingerprint(const char *str, int nbytes, int msglevel, struct gc_arenif (term !=0 || i != nbytes-1 ) {msg (msglevel,"hash fingerprint is different length than expected (%d bytes): %s" , nbytes, str); +return NULL ; }return ret; } +/** +* Parses a string consisting of multiple lines of hexstrings and checks if each +* string has the correct length. Empty lines are ignored. Returns +* a linked list of (possibly) multiple verify_hash_list objects. +* +* @param str String to check/parse +* @param nbytes Number of bytes expected in the hexstring (e.g. 20 for SHA1) +* @param msglevel message level to use when printing warnings/errors +* @param gc The returned list items will be allocated in this gc +*/ +static struct verify_hash_list * +parse_hash_fingerprint_multiline (const char *str,int nbytes,int msglevel, +struct gc_arena *gc) +{ +struct gc_arena gc_temp =gc_new (); +char *lines =string_alloc (str, &gc_temp); + +struct verify_hash_list *ret =NULL ; + +const char *line; +while ((line =strsep (&lines,"\n" ))) + { +/* skip empty lines */ +if (strlen (line) ==0 ) + { +continue ; + } + +struct verify_hash_list *hash =parse_hash_fingerprint (line, nbytes, + msglevel, gc); + +if (!hash) + { +gc_free (&gc_temp); +return NULL ; + } + + hash->next = ret; + ret = hash; + } +gc_free (&gc_temp); + +return ret; +}#ifdef _WIN32#ifndef ENABLE_SMALL @@ -8063,22 +8120,50 @@ add_option(struct options *options, }else if (streq (p[0 ],"verify-hash" ) && p[1 ] && !p[3 ]) { -VERIFY_PERMISSION (OPT_P_GENERAL ); +VERIFY_PERMISSION (OPT_P_GENERAL |OPT_P_INLINE ); + options->verify_hash_algo =MD_SHA256 ; + +int digest_len =SHA256_DIGEST_LENGTH ; -if (!p[2 ] || (p[2 ] &&streq (p[2 ],"SHA1" ))) +if ((!p[2 ] && !is_inline) || (p[2 ] &&streq (p[2 ],"SHA1" ))) { - options->verify_hash =parse_hash_fingerprint (p[1 ],SHA_DIGEST_LENGTH , msglevel, &options->gc); options->verify_hash_algo =MD_SHA1 ; +msg (M_WARN ,"DEPRECATED FEATURE: Usage of SHA1 fingerprints for " +"verify-hash is deprecated. You should switch to SHA256." ); + options->verify_hash_algo =MD_SHA1 ; + digest_len =SHA_DIGEST_LENGTH ; + } +else if (p[2 ] && !streq (p[2 ],"SHA256" ))
src/openvpn/options.c add_option(struct options *options, · line 8146
Quoted 10 lines
src/openvpn/options.c +10
-0+ { +msg (msglevel,"invalid or unsupported hashing algorithm: %s (only SHA1 and SHA256 are valid)" , p[2 ]); + goto err; + } + +struct verify_hash_list *newlist; +if (is_inline) + { + newlist =parse_hash_fingerprint_multiline (p[1 ], digest_len, msglevel, + &options->gc);
indentation is now off here
src/openvpn/options.c add_option(struct options *options, · line 8151
Quoted 8 lines
src/openvpn/options.c +3
-3} -else if (p[2 ] &&streq (p[2 ],"SHA256" )) +else { - options->verify_hash =parse_hash_fingerprint (p[1 ],SHA256_DIGEST_LENGTH , msglevel, &options->gc); - options->verify_hash_algo =MD_SHA256 ; + newlist =parse_hash_fingerprint (p[1 ], digest_len, msglevel, + &options->gc);
same here
src/openvpn/options.c add_option(struct options *options, · line 8152
Quoted 1 line
src/openvpn/options.c +1
-0+ }
Can we just kill the if above and always callparse_hash_fingerprint_multiline() ?
This function should just work for both cases.
Quoted 7 lines
src/openvpn/options.c +5
-0+ +/* Append the new list to the end of our current list */ +if (!options->verify_hash) + { + options->verify_hash = newlist; }else
src/openvpn/options.c add_option(struct options *options, · line 8167
Quoted 10 lines
src/openvpn/options.c +6
-2{ -msg (msglevel,"invalid or unsupported hashing algorithm: %s (only SHA1 and SHA256 are valid)" , p[2 ]); - goto err; +struct verify_hash_list *listend = options->verify_hash; +while (listend->next) + { + listend = listend->next; + } + listend->next = newlist; }
why not prepending instead of appending? prepending will require 1/10th of the code above.
Actually you do prepending already when parsing the inlined peer-fingerprint.
Quoted 50 lines
src/openvpn/options.c +0
-0}#ifdef ENABLE_CRYPTOAPI src/openvpn/options.h +9
-1@@ -191,6 +191,14 @@ enum genkey_type {GENKEY_AUTH_TOKEN }; +struct verify_hash_list +{ +/* We support SHA256 and SHA1 fingerpint. In the case of using the +* deprecated SHA1, only the first 20 bytes of each list item are used */ +uint8_t hash[SHA256_DIGEST_LENGTH ]; +struct verify_hash_list *next; +}; +/* Command line options */ struct options {@@ -550,7 +558,7 @@ struct optionsint ns_cert_type;/* set to 0, NS_CERT_CHECK_SERVER, or NS_CERT_CHECK_CLIENT */ unsigned remote_cert_ku[MAX_PARMS ];const char *remote_cert_eku; -uint8_t *verify_hash; +struct verify_hash_list *verify_hash;hash_algo_type verify_hash_algo;unsigned int ssl_flags;/* set to SSLF_x flags from ssl.h */ src/openvpn/ssl_common.h +1
-1@@ -283,7 +283,7 @@ struct tls_optionsint ns_cert_type;unsigned remote_cert_ku[MAX_PARMS ];const char *remote_cert_eku; -uint8_t *verify_hash; +struct verify_hash_list *verify_hash;hash_algo_type verify_hash_algo;#ifdef ENABLE_X509ALTUSERNAME char *x509_username_field[MAX_PARMS ];src/openvpn/ssl_verify.c +0
-0@@ -748,9 +748,22 @@ verify_cert(struct tls_session *session, openvpn_x509_cert_t *cert, int cert_dep goto cleanup; }
src/openvpn/ssl_verify.c verify_cert(struct tls_session *session, openvpn_x509_cert_t *cert, int cert_dep · line 758
Quoted 10 lines
src/openvpn/ssl_verify.c +8
-1-if (memcmp (BPTR (&ca_hash), opt->verify_hash,BLEN (&ca_hash))) +struct verify_hash_list *current_hash = opt->verify_hash; + +while (current_hash) + { +if (memcmp_constant_time (BPTR (&ca_hash), current_hash->hash, +BLEN (&ca_hash)) ==0 ) + { + hash_matched = true;
ehm, this variable is gone now :) the line above should go too.
Quoted 13 lines
src/openvpn/ssl_verify.c +7
-1+break ; + } + current_hash = current_hash->next; + } + +if (!current_hash) { -msg (D_TLS_ERRORS ,"TLS Error: level-1 certificate hash verification failed" ); +msg (D_TLS_ERRORS ,"TLS Error: --tls-verify certificate hash verification failed" ); goto cleanup; } }
Signature · 1 line
Antonio Quartulli
Re: [Openvpn-devel] [PATCH v2 2/5] Implement peer-fingerprint to check fingerprint of peer certificate
In reply to Arne SchwabeHi,
Quoted 140 lines · Arne Schwabe
This option allows to pin one or more more peer certificates. It also prepares for doing TLS authentication without a CA and just self-signed certificates.
Patch V2: Allow peer-fingerprint to be specified multiple times
to allow multiple peers without needing to use inline syntax. (e.g. on command line).Signed-off-by Arne Schwabe <[email protected]...>--- Changes.rst | 9 ++++++- doc/man-sections/inline-files.rst | 4 +-- doc/man-sections/tls-options.rst | 22 +++++++++++++++- src/openvpn/init.c | 1 + src/openvpn/options.c | 43 ++++++++++++++++++++++++------- src/openvpn/options.h | 1 + src/openvpn/ssl_common.h | 1 + src/openvpn/ssl_verify.c | 19 ++++++++------ 8 files changed, 78 insertions(+), 22 deletions(-)Changes.rst +8
-1@@ -22,13 +22,20 @@ Compatibility with OpenSSL in FIPS mode Deprecated features ------------------- -``inetd`` has been removed +``inetd`` has been removed This was a very limited and not-well-tested way to run OpenVPN, on TCP and TAP mode only. Overview of changes in 2.5 ========================== +New features in 2.5.1 +--------------------- +Certificate pinning/verify peer fingerprint + The ``--peer-fingerprint`` option has been introduced to give users an + easy to use alternative to the ``tls-verify`` for matching the + fingerprint of the peer. The option takes use a number of allowed + SHA256 certificate fingerprints. New features ------------doc/man-sections/inline-files.rst +2
-2@@ -4,8 +4,8 @@ INLINE FILE SUPPORT OpenVPN allows including files in the main configuration for the ``--ca``, ``--cert``, ``--dh``, ``--extra-certs``, ``--key``, ``--pkcs12``, ``--secret``, ``--crl-verify``, ``--http-proxy-user-pass``, ``--tls-auth``, -``--auth-gen-token-secret``, ``--tls-crypt``, ``--tls-crypt-v2`` and -``--verify-hash`` options. +``--auth-gen-token-secret``, ``--peer-fingerprint``, ``--tls-crypt``, +``--tls-crypt-v2`` and ``--verify-hash`` options. Each inline file started by the line ``<option>`` and ended by the line ``</option>``doc/man-sections/tls-options.rst +21
-1@@ -271,7 +271,8 @@ certificates and keys: https://github.com/OpenVPN/easy-rsa man-in-the-middle attack where an authorized client attempts to connect to another client by impersonating the server. The attack is easily prevented by having clients verify the server certificate using any one - of ``--remote-cert-tls``, ``--verify-x509-name``, or ``--tls-verify``. + of ``--remote-cert-tls``, ``--verify-x509-name``, ``--peer-fingerprint`` + or ``--tls-verify``. --tls-auth args Add an additional layer of HMAC authentication on top of the TLS control@@ -592,6 +593,25 @@ certificates and keys: https://github.com/OpenVPN/easy-rsa If the option is inlined, ``algo`` is always :code:`SHA256`. +--peer-fingerprint args + Specify a SHA256 fingerprint or list of SHA256 fingerprints to verify + the peer certificate against. The peer certificate must match one of the + fingerprint or certificate verification will fail. The option can also + be inlined + + Valid syntax: + :: + + peer-fingerprint AD:B0:95:D8:09:... + + or inline: + :: + + <peer-fingerprint> + 00:11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff:00:11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff + 11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff:00:11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff:00 + </peer-fingerprint> + --verify-x509-name args Accept connections only if a host's X.509 name is equal to **name.** The remote host must also pass all other tests of verification.src/openvpn/init.c +1
-0@@ -2927,6 +2927,7 @@ do_init_crypto_tls(struct context *c, const unsigned int flags) to.remote_cert_eku = options->remote_cert_eku; to.verify_hash = options->verify_hash; to.verify_hash_algo = options->verify_hash_algo; + to.verify_hash_depth = options->verify_hash_depth;#ifdef ENABLE_X509ALTUSERNAME memcpy (to.x509_username_field, options->x509_username_field,sizeof (to.x509_username_field));#else src/openvpn/options.c +11
-2@@ -8118,25 +8118,47 @@ add_option(struct options *options, options->extra_certs_file = p[1 ]; options->extra_certs_file_inline = is_inline; } -else if (streq (p[0 ],"verify-hash" ) && p[1 ] && !p[3 ]) +else if ((streq (p[0 ],"verify-hash" ) && p[1 ] && !p[3 ]) + || (streq (p[0 ],"peer-fingerprint" ) && p[1 ] && !p[2 ])) {VERIFY_PERMISSION (OPT_P_GENERAL |OPT_P_INLINE ); + +int verify_hash_depth =0 ; +if (streq (p[0 ],"verify-hash" )) + { +/* verify level 1 cert, i.e. the CA that signed the leaf cert */ + verify_hash_depth =1 ; + } + options->verify_hash_algo =MD_SHA256 ;int digest_len =SHA256_DIGEST_LENGTH ; -if ((!p[2 ] && !is_inline) || (p[2 ] &&streq (p[2 ],"SHA1" ))) +if (options->verify_hash && options->verify_hash_depth != verify_hash_depth)
src/openvpn/options.c add_option(struct options *options, · line 8142
Quoted 10 lines
src/openvpn/options.c +4
-5{ - options->verify_hash_algo =MD_SHA1 ; -msg (M_WARN ,"DEPRECATED FEATURE: Usage of SHA1 fingerprints for " -"verify-hash is deprecated. You should switch to SHA256." ); - options->verify_hash_algo =MD_SHA1 ; - digest_len =SHA_DIGEST_LENGTH ; +msg (msglevel,"ERROR: Setting %s not allowed. Option to verify " +"fingerprint of certificate of peer certificate " +"(--verify-hash or --peer-fingerprint) already set." , + p[0 ]);
How about changing this message to "--verify-hash and --peer-fingerprint are mutually exclusive" ?
Saying that "Setting --verify-hash not allowed" is not very clear imho - and the message will change based on the order.
src/openvpn/options.c add_option(struct options *options, · line 8152
Quoted 13 lines
src/openvpn/options.c +8
-3+ goto err; } -else if (p[2 ] && !streq (p[2 ],"SHA256" )) + +if (streq (p[0 ],"verify-hash" )) { -msg (msglevel,"invalid or unsupported hashing algorithm: %s (only SHA1 and SHA256 are valid)" , p[2 ]); - goto err; +if ((!p[2 ] && !is_inline) || (p[2 ] &&streq (p[2 ],"SHA1" ))) + { + options->verify_hash_algo =MD_SHA1 ; +msg (M_WARN ,"DEPRECATED FEATURE: Usage of SHA1 fingerprints for " + "verify-hash is deprecated. You should switch to the "
-the
Quoted 87 lines
src/openvpn/options.c +10
-0+ "SHA256."); + options->verify_hash_algo =SHA_DIGEST_LENGTH ; + digest_len =SHA_DIGEST_LENGTH ; + } +else if (p[2 ] && !streq (p[2 ],"SHA256" )) + { +msg (msglevel,"invalid or unsupported hashing algorithm: %s (only SHA1 and SHA256 are valid)" , p[2 ]); + goto err; + } }struct verify_hash_list *newlist;@@ -8155,6 +8177,7 @@ add_option(struct options *options,if (!options->verify_hash) { options->verify_hash = newlist; + options->verify_hash_depth = verify_hash_depth; }else {src/openvpn/options.h +1
-0@@ -560,6 +560,7 @@ struct optionsconst char *remote_cert_eku;struct verify_hash_list *verify_hash;hash_algo_type verify_hash_algo; +int verify_hash_depth;unsigned int ssl_flags;/* set to SSLF_x flags from ssl.h */ #ifdef ENABLE_PKCS11 src/openvpn/ssl_common.h +1
-0@@ -284,6 +284,7 @@ struct tls_optionsunsigned remote_cert_ku[MAX_PARMS ];const char *remote_cert_eku;struct verify_hash_list *verify_hash; +int verify_hash_depth;hash_algo_type verify_hash_algo;#ifdef ENABLE_X509ALTUSERNAME char *x509_username_field[MAX_PARMS ];src/openvpn/ssl_verify.c +6
-7@@ -721,19 +721,18 @@ verify_cert(struct tls_session *session, openvpn_x509_cert_t *cert, int cert_dep goto cleanup;/* Reject connection */ } -/* verify level 1 cert, i.e. the CA that signed our leaf cert */ -if (cert_depth ==1 && opt->verify_hash) +if (cert_depth == opt->verify_hash_depth && opt->verify_hash) { -struct buffer ca_hash = {0 }; +struct buffer cert_fp = {0 };switch (opt->verify_hash_algo) {case MD_SHA1 : - ca_hash =x509_get_sha1_fingerprint (cert, &gc); + cert_fp =x509_get_sha1_fingerprint (cert, &gc);break ;case MD_SHA256 : - ca_hash =x509_get_sha256_fingerprint (cert, &gc); + cert_fp =x509_get_sha256_fingerprint (cert, &gc);break ;default :@@ -752,8 +751,8 @@ verify_cert(struct tls_session *session, openvpn_x509_cert_t *cert, int cert_depwhile (current_hash) { -if (memcmp_constant_time (BPTR (&ca_hash), current_hash->hash, -BLEN (&ca_hash)) ==0 ) +if (memcmp_constant_time (BPTR (&cert_fp), current_hash->hash, +BLEN (&cert_fp)) ==0 ) { hash_matched = true;break ;@@ -763,7 +762,11 @@ verify_cert(struct tls_session *session, openvpn_x509_cert_t *cert, int cert_depif (!current_hash)
src/openvpn/ssl_verify.c verify_cert(struct tls_session *session, openvpn_x509_cert_t *cert, int cert_dep · line 772
Quoted 10 lines
src/openvpn/ssl_verify.c +5
-1{ -msg (D_TLS_ERRORS ,"TLS Error: --tls-verify certificate hash verification failed" ); +const char *hex_fp =format_hex_ex (BPTR (&cert_fp),BLEN (&cert_fp), +0 ,1 ,":" , &gc); +msg (D_TLS_ERRORS ,"TLS Error: --tls-verify/--peer-fingerprint" +"certificate hash verification failed. (got " +"fingerprint: %s" , hex_fp); goto cleanup; } }
Other that the minor comment above this patch looks good. But I will ACK once I have a 1/5 that I can base this on.
Cheers,
Signature · 1 line
Antonio Quartulli
PATCH v3 1/1 Extend verify-hash to allow multiple hashes
In reply to Arne SchwabeThis patch introduces support for verify-hash inlining.
When inlined, this options now allows to specify multiple fingerprints, one per line.
Since this is a new syntax, there is no backwards compatibility to take care of, therefore we can drop support for SHA1. Inlined fingerprints are assumed be to SHA-256 only.
Also print a warning about SHA1 hash being deprecated to verify certificates as it is not "industry standard" anymore.
Patch v2: fix/clarify various comments, fix a few minor problems, allow
the option to be specified multiple times and have that added to the list.
Patch v3: Remove leftover variable, always call
parse_hash_fingerprint_multiline, add comments clarifying list appending
--- doc/man-sections/inline-files.rst | 4 +- doc/man-sections/tls-options.rst | 10 +++ src/openvpn/options.c | 102 ++++++++++++++++++++++++++---- src/openvpn/options.h | 10 ++- src/openvpn/ssl_common.h | 2 +- src/openvpn/ssl_verify.c | 16 ++++- 6 files changed, 127 insertions(+), 17 deletions(-)
doc/man-sections/inline-files.rst +2 -2
@@ -4,8 +4,8 @@ INLINE FILE SUPPORT OpenVPN allows including files in the main configuration for the ``--ca``, ``--cert``, ``--dh``, ``--extra-certs``, ``--key``, ``--pkcs12``, ``--secret``, ``--crl-verify``, ``--http-proxy-user-pass``, ``--tls-auth``, -``--auth-gen-token-secret``, ``--tls-crypt`` and ``--tls-crypt-v2`` -options. +``--auth-gen-token-secret``, ``--tls-crypt``, ``--tls-crypt-v2`` and +``--verify-hash`` options. Each inline file started by the line ``<option>`` and ended by the line ``</option>``
doc/man-sections/tls-options.rst +10 -0
@@ -582,6 +582,16 @@ certificates and keys: https://github.com/OpenVPN/easy-rsa The ``algo`` flag can be either :code:`SHA1` or :code:`SHA256`. If not provided, it defaults to :code:`SHA1`. + This option can also be inlined + :: + + <verify-hash> + 00:11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff:00:11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff + 11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff:00:11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff:00 + </verify-hash> + +If the option is inlined, ``algo`` is always :code:`SHA256`. + --verify-x509-name args Accept connections only if a host's X.509 name is equal to **name.** The remote host must also pass all other tests of verification.
src/openvpn/options.c +91 -11
142 lines not on this page · raw message
src/openvpn/options.h +9 -1
@@ -191,6 +191,14 @@ enum genkey_type {GENKEY_AUTH_TOKEN }; +struct verify_hash_list +{ +/* We support SHA256 and SHA1 fingerpint. In the case of using the +* deprecated SHA1, only the first 20 bytes of each list item are used */ +uint8_t hash[SHA256_DIGEST_LENGTH ]; +struct verify_hash_list *next; +}; +/* Command line options */ struct options {
@@ -550,7 +558,7 @@ struct optionsint ns_cert_type;/* set to 0, NS_CERT_CHECK_SERVER, or NS_CERT_CHECK_CLIENT */ unsigned remote_cert_ku[MAX_PARMS ];const char *remote_cert_eku; -uint8_t *verify_hash; +struct verify_hash_list *verify_hash;hash_algo_type verify_hash_algo;unsigned int ssl_flags;/* set to SSLF_x flags from ssl.h */
src/openvpn/ssl_common.h +1 -1
@@ -283,7 +283,7 @@ struct tls_optionsint ns_cert_type;unsigned remote_cert_ku[MAX_PARMS ];const char *remote_cert_eku; -uint8_t *verify_hash; +struct verify_hash_list *verify_hash;hash_algo_type verify_hash_algo;#ifdef ENABLE_X509ALTUSERNAME char *x509_username_field[MAX_PARMS ];
src/openvpn/ssl_verify.c +14 -2
@@ -748,9 +748,21 @@ verify_cert(struct tls_session *session, openvpn_x509_cert_t *cert, int cert_dep goto cleanup; } -if (memcmp (BPTR (&ca_hash), opt->verify_hash,BLEN (&ca_hash))) +struct verify_hash_list *current_hash = opt->verify_hash; + +while (current_hash) + { +if (memcmp_constant_time (BPTR (&ca_hash), current_hash->hash, +BLEN (&ca_hash)) ==0 ) + { +break ; + } + current_hash = current_hash->next; + } + +if (!current_hash) { -msg (D_TLS_ERRORS ,"TLS Error: level-1 certificate hash verification failed" ); +msg (D_TLS_ERRORS ,"TLS Error: --tls-verify certificate hash verification failed" ); goto cleanup; } }
Signature · 1 line
2.30.1
PATCH v3 1/1 Implement peer-fingerprint to check fingerprint of peer certificate
In reply to Arne SchwabeThis option allows to pin one or more more peer certificates. It also prepares for doing TLS authentication without a CA and just self-signed certificates.
Patch V2: Allow peer-fingerprint to be specified multiple times
to allow multiple peers without needing to use inline syntax. (e.g. on command line).
Patch V3: rebase on v3 of 1/4, reword message of verify-hash and
peer-fingerpring incompatibility
--- Changes.rst | 9 ++++++- doc/man-sections/inline-files.rst | 4 +-- doc/man-sections/tls-options.rst | 22 +++++++++++++++- src/openvpn/init.c | 1 + src/openvpn/options.c | 42 +++++++++++++++++++++++-------- src/openvpn/options.h | 1 + src/openvpn/ssl_common.h | 1 + src/openvpn/ssl_verify.c | 19 ++++++++------ 8 files changed, 76 insertions(+), 23 deletions(-)
Changes.rst +8 -1
@@ -22,13 +22,20 @@ Compatibility with OpenSSL in FIPS mode Deprecated features ------------------- -``inetd`` has been removed +``inetd`` has been removed This was a very limited and not-well-tested way to run OpenVPN, on TCP and TAP mode only. Overview of changes in 2.5 ========================== +New features in 2.5.1 +--------------------- +Certificate pinning/verify peer fingerprint + The ``--peer-fingerprint`` option has been introduced to give users an + easy to use alternative to the ``tls-verify`` for matching the + fingerprint of the peer. The option takes use a number of allowed + SHA256 certificate fingerprints. New features ------------
doc/man-sections/inline-files.rst +2 -2
@@ -4,8 +4,8 @@ INLINE FILE SUPPORT OpenVPN allows including files in the main configuration for the ``--ca``, ``--cert``, ``--dh``, ``--extra-certs``, ``--key``, ``--pkcs12``, ``--secret``, ``--crl-verify``, ``--http-proxy-user-pass``, ``--tls-auth``, -``--auth-gen-token-secret``, ``--tls-crypt``, ``--tls-crypt-v2`` and -``--verify-hash`` options. +``--auth-gen-token-secret``, ``--peer-fingerprint``, ``--tls-crypt``, +``--tls-crypt-v2`` and ``--verify-hash`` options. Each inline file started by the line ``<option>`` and ended by the line ``</option>``
doc/man-sections/tls-options.rst +21 -1
@@ -271,7 +271,8 @@ certificates and keys: https://github.com/OpenVPN/easy-rsa man-in-the-middle attack where an authorized client attempts to connect to another client by impersonating the server. The attack is easily prevented by having clients verify the server certificate using any one - of ``--remote-cert-tls``, ``--verify-x509-name``, or ``--tls-verify``. + of ``--remote-cert-tls``, ``--verify-x509-name``, ``--peer-fingerprint`` + or ``--tls-verify``. --tls-auth args Add an additional layer of HMAC authentication on top of the TLS control
@@ -592,6 +593,25 @@ certificates and keys: https://github.com/OpenVPN/easy-rsa If the option is inlined, ``algo`` is always :code:`SHA256`. +--peer-fingerprint args + Specify a SHA256 fingerprint or list of SHA256 fingerprints to verify + the peer certificate against. The peer certificate must match one of the + fingerprint or certificate verification will fail. The option can also + be inlined + + Valid syntax: + :: + + peer-fingerprint AD:B0:95:D8:09:... + + or inline: + :: + + <peer-fingerprint> + 00:11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff:00:11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff + 11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff:00:11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff:00 + </peer-fingerprint> + --verify-x509-name args Accept connections only if a host's X.509 name is equal to **name.** The remote host must also pass all other tests of verification.
src/openvpn/init.c +1 -0
@@ -2927,6 +2927,7 @@ do_init_crypto_tls(struct context *c, const unsigned int flags) to.remote_cert_eku = options->remote_cert_eku; to.verify_hash = options->verify_hash; to.verify_hash_algo = options->verify_hash_algo; + to.verify_hash_depth = options->verify_hash_depth;#ifdef ENABLE_X509ALTUSERNAME memcpy (to.x509_username_field, options->x509_username_field,sizeof (to.x509_username_field));#else
src/openvpn/options.c +31 -11
63 lines not on this page · raw message
src/openvpn/options.h +1 -0
@@ -560,6 +560,7 @@ struct optionsconst char *remote_cert_eku;struct verify_hash_list *verify_hash;hash_algo_type verify_hash_algo; +int verify_hash_depth;unsigned int ssl_flags;/* set to SSLF_x flags from ssl.h */ #ifdef ENABLE_PKCS11
src/openvpn/ssl_common.h +1 -0
@@ -284,6 +284,7 @@ struct tls_optionsunsigned remote_cert_ku[MAX_PARMS ];const char *remote_cert_eku;struct verify_hash_list *verify_hash; +int verify_hash_depth;hash_algo_type verify_hash_algo;#ifdef ENABLE_X509ALTUSERNAME char *x509_username_field[MAX_PARMS ];
src/openvpn/ssl_verify.c +11 -8
@@ -721,19 +721,18 @@ verify_cert(struct tls_session *session, openvpn_x509_cert_t *cert, int cert_dep goto cleanup;/* Reject connection */ } -/* verify level 1 cert, i.e. the CA that signed our leaf cert */ -if (cert_depth ==1 && opt->verify_hash) +if (cert_depth == opt->verify_hash_depth && opt->verify_hash) { -struct buffer ca_hash = {0 }; +struct buffer cert_fp = {0 };switch (opt->verify_hash_algo) {case MD_SHA1 : - ca_hash =x509_get_sha1_fingerprint (cert, &gc); + cert_fp =x509_get_sha1_fingerprint (cert, &gc);break ;case MD_SHA256 : - ca_hash =x509_get_sha256_fingerprint (cert, &gc); + cert_fp =x509_get_sha256_fingerprint (cert, &gc);break ;default :
@@ -752,8 +751,8 @@ verify_cert(struct tls_session *session, openvpn_x509_cert_t *cert, int cert_depwhile (current_hash) { -if (memcmp_constant_time (BPTR (&ca_hash), current_hash->hash, -BLEN (&ca_hash)) ==0 ) +if (memcmp_constant_time (BPTR (&cert_fp), current_hash->hash, +BLEN (&cert_fp)) ==0 ) {break ; }
@@ -762,7 +761,11 @@ verify_cert(struct tls_session *session, openvpn_x509_cert_t *cert, int cert_depif (!current_hash) { -msg (D_TLS_ERRORS ,"TLS Error: --tls-verify certificate hash verification failed" ); +const char *hex_fp =format_hex_ex (BPTR (&cert_fp),BLEN (&cert_fp), +0 ,1 ,":" , &gc); +msg (D_TLS_ERRORS ,"TLS Error: --tls-verify/--peer-fingerprint" +"certificate hash verification failed. (got " +"fingerprint: %s" , hex_fp); goto cleanup; } }
Signature · 1 line
2.30.1
Hi,
This patch looks good to me.
There is just one minor note below:
Quoted 106 lines · Arne Schwabe
This patch introduces support for verify-hash inlining.
When inlined, this options now allows to specify multiple fingerprints, one per line.Since this is a new syntax, there is no backwards compatibility to take care of, therefore we can drop support for SHA1. Inlined fingerprints are assumed be to SHA-256 only.
Also print a warning about SHA1 hash being deprecated to verify certificates as it is not "industry standard" anymore.
Patch v2: fix/clarify various comments, fix a few minor problems, allow
the option to be specified multiple times and have that added to the list.Patch v3: Remove leftover variable, always call
parse_hash_fingerprint_multiline, add comments clarifying list appendingSigned-off-by Arne Schwabe <[email protected]...>--- doc/man-sections/inline-files.rst | 4 +- doc/man-sections/tls-options.rst | 10 +++ src/openvpn/options.c | 102 ++++++++++++++++++++++++++---- src/openvpn/options.h | 10 ++- src/openvpn/ssl_common.h | 2 +- src/openvpn/ssl_verify.c | 16 ++++- 6 files changed, 127 insertions(+), 17 deletions(-)doc/man-sections/inline-files.rst +2
-2@@ -4,8 +4,8 @@ INLINE FILE SUPPORT OpenVPN allows including files in the main configuration for the ``--ca``, ``--cert``, ``--dh``, ``--extra-certs``, ``--key``, ``--pkcs12``, ``--secret``, ``--crl-verify``, ``--http-proxy-user-pass``, ``--tls-auth``, -``--auth-gen-token-secret``, ``--tls-crypt`` and ``--tls-crypt-v2`` -options. +``--auth-gen-token-secret``, ``--tls-crypt``, ``--tls-crypt-v2`` and +``--verify-hash`` options. Each inline file started by the line ``<option>`` and ended by the line ``</option>``doc/man-sections/tls-options.rst +10
-0@@ -582,6 +582,16 @@ certificates and keys: https://github.com/OpenVPN/easy-rsa The ``algo`` flag can be either :code:`SHA1` or :code:`SHA256`. If not provided, it defaults to :code:`SHA1`. + This option can also be inlined + :: + + <verify-hash> + 00:11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff:00:11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff + 11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff:00:11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff:00 + </verify-hash> + +If the option is inlined, ``algo`` is always :code:`SHA256`. + --verify-x509-name args Accept connections only if a host's X.509 name is equal to **name.** The remote host must also pass all other tests of verification.src/openvpn/options.c +15
-3@@ -1078,12 +1078,24 @@ string_substitute(const char *src, int from, int to, struct gc_arena *gc)return ret; } -static uint8_t * +/** +* Parses a hexstring and checks if the string has the correct length. Return +* a verify_hash_list containing the parsed hash string. +* +* @param str String to check/parse +* @param nbytes Number of bytes expected in the hexstr (e.g. 20 for SHA1) +* @param msglevel message level to use when printing warnings/errors +* @param gc The returned object will be allocated in this gc +*/ +static struct verify_hash_list *parse_hash_fingerprint (const char *str,int nbytes,int msglevel,struct gc_arena *gc) {int i;const char *cp = str; -uint8_t *ret = (uint8_t *)gc_malloc (nbytes, true, gc); + +struct verify_hash_list *ret; + ALLOC_OBJ_CLEAR_GC(ret, struct verify_hash_list, gc); +char term =1 ;int byte;char bs[3 ];@@ -1102,7 +1114,7 @@ parse_hash_fingerprint(const char *str, int nbytes, int msglevel, struct gc_aren {msg (msglevel,"format error in hash fingerprint hex byte: %s" , str); } - ret[i] = (uint8_t )byte; + ret->hash[i] = (uint8_t )byte; term = *cp++;if (term !=':' && term !=0 ) {
src/openvpn/options.c parse_hash_fingerprint(const char *str, int nbytes, int msglevel, struct gc_aren · line 1131
Quoted 4 lines
src/openvpn/options.c +1
-0@@ -1116,10 +1128,55 @@ parse_hash_fingerprint(const char *str, int nbytes, int msglevel, struct gc_arenif (term !=0 || i != nbytes-1 ) {msg (msglevel,"hash fingerprint is different length than expected (%d bytes): %s" , nbytes, str); +return NULL ;
The rest of this function assumes that msglevel is set to a FATAL level.
As you can also see in the hunk above, if blocks handling other errors have no return statement, because they assume the program will exit there.
Personally I find this style very counter intuitive.
Also we should consider that the msglevel is a variable here, so this very function CANNOT assume that the msglevel contains the FATAL bit.
Imagine using this function in a another context in the future, while forgetting about this hidden assumption: disaster.
Now, this problem is mostly unrelated to this patch.
We just have to make a decision here:
1) remove the "return NULL" (it's just above my text), in order to follow the current function's style - because the return will never be hit; or
2) accept the patch as is and move on.
In both cases, this patch gets my ACK.
The error handling in the option parser is a topic we could discuss in a meeting.
Cheers,
Signature · 1 line
Antonio Quartulli
Re: [Openvpn-devel] [PATCH v3] Implement peer-fingerprint to check fingerprint of peer certificate
In reply to Arne SchwabeHi,
Quoted 28 lines · Arne Schwabe
This option allows to pin one or more more peer certificates. It also prepares for doing TLS authentication without a CA and just self-signed certificates.
Patch V2: Allow peer-fingerprint to be specified multiple times
to allow multiple peers without needing to use inline syntax. (e.g. on command line).Patch V3: rebase on v3 of 1/4, reword message of verify-hash and
peer-fingerpring incompatibilitySigned-off-by Arne Schwabe <[email protected]...>--- Changes.rst | 9 ++++++- doc/man-sections/inline-files.rst | 4 +-- doc/man-sections/tls-options.rst | 22 +++++++++++++++- src/openvpn/init.c | 1 + src/openvpn/options.c | 42 +++++++++++++++++++++++-------- src/openvpn/options.h | 1 + src/openvpn/ssl_common.h | 1 + src/openvpn/ssl_verify.c | 19 ++++++++------ 8 files changed, 76 insertions(+), 23 deletions(-)Changes.rst +0
-0
Changes.rst Compatibility with OpenSSL in FIPS mode · line 25
Quoted 5 lines
Changes.rst +1
-1@@ -22,13 +22,20 @@ Compatibility with OpenSSL in FIPS mode Deprecated features ------------------- -``inetd`` has been removed +``inetd`` has been removed
I guess this is just a mistake.
Changes.rst Compatibility with OpenSSL in FIPS mode · line 32
Quoted 7 lines
Changes.rst +1
-0This was a very limited and not-well-tested way to run OpenVPN, on TCP and TAP mode only. Overview of changes in 2.5 ========================== +New features in 2.5.1
I believe this feature was meant to target master/2.6, therefore putting it under 2.5.1 was probably a mistake.
Quoted 212 lines
Changes.rst +6
-0+--------------------- +Certificate pinning/verify peer fingerprint + The ``--peer-fingerprint`` option has been introduced to give users an + easy to use alternative to the ``tls-verify`` for matching the + fingerprint of the peer. The option takes use a number of allowed + SHA256 certificate fingerprints. New features ------------doc/man-sections/inline-files.rst +2
-2@@ -4,8 +4,8 @@ INLINE FILE SUPPORT OpenVPN allows including files in the main configuration for the ``--ca``, ``--cert``, ``--dh``, ``--extra-certs``, ``--key``, ``--pkcs12``, ``--secret``, ``--crl-verify``, ``--http-proxy-user-pass``, ``--tls-auth``, -``--auth-gen-token-secret``, ``--tls-crypt``, ``--tls-crypt-v2`` and -``--verify-hash`` options. +``--auth-gen-token-secret``, ``--peer-fingerprint``, ``--tls-crypt``, +``--tls-crypt-v2`` and ``--verify-hash`` options. Each inline file started by the line ``<option>`` and ended by the line ``</option>``doc/man-sections/tls-options.rst +21
-1@@ -271,7 +271,8 @@ certificates and keys: https://github.com/OpenVPN/easy-rsa man-in-the-middle attack where an authorized client attempts to connect to another client by impersonating the server. The attack is easily prevented by having clients verify the server certificate using any one - of ``--remote-cert-tls``, ``--verify-x509-name``, or ``--tls-verify``. + of ``--remote-cert-tls``, ``--verify-x509-name``, ``--peer-fingerprint`` + or ``--tls-verify``. --tls-auth args Add an additional layer of HMAC authentication on top of the TLS control@@ -592,6 +593,25 @@ certificates and keys: https://github.com/OpenVPN/easy-rsa If the option is inlined, ``algo`` is always :code:`SHA256`. +--peer-fingerprint args + Specify a SHA256 fingerprint or list of SHA256 fingerprints to verify + the peer certificate against. The peer certificate must match one of the + fingerprint or certificate verification will fail. The option can also + be inlined + + Valid syntax: + :: + + peer-fingerprint AD:B0:95:D8:09:... + + or inline: + :: + + <peer-fingerprint> + 00:11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff:00:11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff + 11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff:00:11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff:00 + </peer-fingerprint> + --verify-x509-name args Accept connections only if a host's X.509 name is equal to **name.** The remote host must also pass all other tests of verification.src/openvpn/init.c +1
-0@@ -2927,6 +2927,7 @@ do_init_crypto_tls(struct context *c, const unsigned int flags) to.remote_cert_eku = options->remote_cert_eku; to.verify_hash = options->verify_hash; to.verify_hash_algo = options->verify_hash_algo; + to.verify_hash_depth = options->verify_hash_depth;#ifdef ENABLE_X509ALTUSERNAME memcpy (to.x509_username_field, options->x509_username_field,sizeof (to.x509_username_field));#else src/openvpn/options.c +31
-11@@ -8118,26 +8118,45 @@ add_option(struct options *options, options->extra_certs_file = p[1 ]; options->extra_certs_file_inline = is_inline; } -else if (streq (p[0 ],"verify-hash" ) && p[1 ] && !p[3 ]) +else if ((streq (p[0 ],"verify-hash" ) && p[1 ] && !p[3 ]) + || (streq (p[0 ],"peer-fingerprint" ) && p[1 ] && !p[2 ])) {VERIFY_PERMISSION (OPT_P_GENERAL |OPT_P_INLINE ); + +int verify_hash_depth =0 ; +if (streq (p[0 ],"verify-hash" )) + { +/* verify level 1 cert, i.e. the CA that signed the leaf cert */ + verify_hash_depth =1 ; + } + options->verify_hash_algo =MD_SHA256 ;int digest_len =SHA256_DIGEST_LENGTH ; -if ((!p[2 ] && !is_inline) || (p[2 ] &&streq (p[2 ],"SHA1" ))) +if (options->verify_hash && options->verify_hash_depth != verify_hash_depth) { - options->verify_hash_algo =MD_SHA1 ; -msg (M_WARN ,"DEPRECATED FEATURE: Usage of SHA1 fingerprints for " -"verify-hash is deprecated. You should switch to SHA256." ); - options->verify_hash_algo =MD_SHA1 ; - digest_len =SHA_DIGEST_LENGTH ; +msg (msglevel,"ERROR: Setting %s not allowed. --verify-hash and" +" --peer-fingerprint are mutually exclusive" , p[0 ]); + goto err; } -else if (p[2 ] && !streq (p[2 ],"SHA256" )) + +if (streq (p[0 ],"verify-hash" )) { -msg (msglevel,"invalid or unsupported hashing algorithm: %s " -"(only SHA1 and SHA256 are valid)" , p[2 ]); - goto err; +if ((!p[2 ] && !is_inline) || (p[2 ] &&streq (p[2 ],"SHA1" ))) + { + options->verify_hash_algo =MD_SHA1 ; +msg (M_WARN ,"DEPRECATED FEATURE: Usage of SHA1 fingerprints for " +"verify-hash is deprecated. You should switch to SHA256." ); + options->verify_hash_algo =SHA_DIGEST_LENGTH ; + digest_len =SHA_DIGEST_LENGTH ; + } +else if (p[2 ] && !streq (p[2 ],"SHA256" )) + { +msg (msglevel,"invalid or unsupported hashing algorithm: %s " +"(only SHA1 and SHA256 are supported)" , p[2 ]); + goto err; + } }struct verify_hash_list *newlist;@@ -8148,6 +8167,7 @@ add_option(struct options *options,if (!options->verify_hash) { options->verify_hash = newlist; + options->verify_hash_depth = verify_hash_depth; }else {src/openvpn/options.h +1
-0@@ -560,6 +560,7 @@ struct optionsconst char *remote_cert_eku;struct verify_hash_list *verify_hash;hash_algo_type verify_hash_algo; +int verify_hash_depth;unsigned int ssl_flags;/* set to SSLF_x flags from ssl.h */ #ifdef ENABLE_PKCS11 src/openvpn/ssl_common.h +1
-0@@ -284,6 +284,7 @@ struct tls_optionsunsigned remote_cert_ku[MAX_PARMS ];const char *remote_cert_eku;struct verify_hash_list *verify_hash; +int verify_hash_depth;hash_algo_type verify_hash_algo;#ifdef ENABLE_X509ALTUSERNAME char *x509_username_field[MAX_PARMS ];src/openvpn/ssl_verify.c +6
-7@@ -721,19 +721,18 @@ verify_cert(struct tls_session *session, openvpn_x509_cert_t *cert, int cert_dep goto cleanup;/* Reject connection */ } -/* verify level 1 cert, i.e. the CA that signed our leaf cert */ -if (cert_depth ==1 && opt->verify_hash) +if (cert_depth == opt->verify_hash_depth && opt->verify_hash) { -struct buffer ca_hash = {0 }; +struct buffer cert_fp = {0 };switch (opt->verify_hash_algo) {case MD_SHA1 : - ca_hash =x509_get_sha1_fingerprint (cert, &gc); + cert_fp =x509_get_sha1_fingerprint (cert, &gc);break ;case MD_SHA256 : - ca_hash =x509_get_sha256_fingerprint (cert, &gc); + cert_fp =x509_get_sha256_fingerprint (cert, &gc);break ;default :@@ -752,8 +751,8 @@ verify_cert(struct tls_session *session, openvpn_x509_cert_t *cert, int cert_depwhile (current_hash) { -if (memcmp_constant_time (BPTR (&ca_hash), current_hash->hash, -BLEN (&ca_hash)) ==0 ) +if (memcmp_constant_time (BPTR (&cert_fp), current_hash->hash, +BLEN (&cert_fp)) ==0 ) {break ; }@@ -762,7 +761,11 @@ verify_cert(struct tls_session *session, openvpn_x509_cert_t *cert, int cert_depif (!current_hash)
src/openvpn/ssl_verify.c verify_cert(struct tls_session *session, openvpn_x509_cert_t *cert, int cert_dep · line 771
Quoted 10 lines
src/openvpn/ssl_verify.c +5
-1{ -msg (D_TLS_ERRORS ,"TLS Error: --tls-verify certificate hash verification failed" ); +const char *hex_fp =format_hex_ex (BPTR (&cert_fp),BLEN (&cert_fp), +0 ,1 ,":" , &gc); +msg (D_TLS_ERRORS ,"TLS Error: --tls-verify/--peer-fingerprint" +"certificate hash verification failed. (got " +"fingerprint: %s" , hex_fp); goto cleanup; } }
Other than those 2 minor notes above the patch looks good.
Not sure it is worth adding to some documentation, but if both peer-fingerprint and tls-verify are specified, the latter check is performed at the end.
Signature · 1 line
Antonio Quartulli
Re: [Openvpn-devel] [PATCH v2 3/5] Support fingerprint authentication without CA certificate
In reply to Arne SchwabeHi,
Quoted 111 lines · Arne Schwabe
From: "Jason A. Donenfeld" <[email protected]...>
OpenVPN traditionally works around CAs. However many TLS-based protocols also allow an alternative simpler mode in which rather than verify certificates against CAs, the certificate itself is hashed and compared against a pre-known set of acceptable hashes. This is usually referred to as "fingerprint verification". It's popular across SMTP servers, IRC servers, XMPP servers, and even in the context of HTTP with pinning.
* Allow not specifying the --ca parameter, to specify that certificates should not be checked against a CA.
I've included some instructions on how to use all of this.
Server side:
============Make self-signed cert:
$ openssl req -x509 -newkey ec:<(openssl ecparam -name secp384r1) -keyout serverkey.pem -out servercert.pem -nodes -sha256 -days 3650 -subj '/CN=server'Record our fingerprint in an environment variable for the client to use later:
$ server_fingerprint="$(openssl x509 -in servercert.pem -noout -sha256 -fingerprint | sed 's/.*=//;s/\(.*\)/\1/')"Client side:
============
Make self-signed cert:$ openssl req -x509 -newkey ec:<(openssl ecparam -name secp384r1) -keyout clientkey.pem -out clientcert.pem -nodes -sha256 -days 3650 -subj '/CN=client'Record our fingerprint in an environment variable for the server to use later:
$ client_fingerprint="$(openssl x509 -in clientcert.pem -noout -sha256 -fingerprint | sed 's/.*=//;s/\(.*\)/\1/')"Start server/client
===================Start openvpn with peer fingerprint verification:
$ sudo openvpn --server 10.66.0.0 255.255.255.0 --dev tun --dh none --cert servercert.pem --key serverkey.pem --peer-fingerprint "$client_fingerprint"$ sudo openvpn --client --remote 127.0.0.1 --dev tun --cert clientcert.pem --key clientkey.pem --peer-fingerprint "$server_fingerprint" --nobindSigned-off-by Jason A. Donenfeld <[email protected]...>Patch V2: Changes in V2 (by Arne Schwabe):
- Only check peer certificates, not all cert levels, if you need multiple levels of certificate you should use a real CA
- Use peer-fingerprint instead tls-verify on server side in example.
- rename variableca_file_nonetoverify_hash_no_ca
- do no require --ca none but allow --ca simply
to be absent when --peer-fingprint is present
- adjust warnings/errors messages to also point to peer-fingerprint as valid verification method.
- Fix mbed TLS version of not requiring CA
not workingSigned-off-by Arne Schwabe <[email protected]...>--- src/openvpn/init.c | 2 ++ src/openvpn/options.c | 30 +++++++++++++++++++++++------- src/openvpn/options.h | 1 + src/openvpn/ssl.c | 2 +- src/openvpn/ssl_common.h | 1 + src/openvpn/ssl_verify_mbedtls.c | 17 +++++++++++++++++ src/openvpn/ssl_verify_openssl.c | 2 +- 7 files changed, 46 insertions(+), 9 deletions(-)src/openvpn/init.c +2
-0@@ -2928,6 +2928,8 @@ do_init_crypto_tls(struct context *c, const unsigned int flags) to.verify_hash = options->verify_hash; to.verify_hash_algo = options->verify_hash_algo; to.verify_hash_depth = options->verify_hash_depth; + to.verify_hash_no_ca = options->verify_hash_no_ca; +#ifdef ENABLE_X509ALTUSERNAME memcpy (to.x509_username_field, options->x509_username_field,sizeof (to.x509_username_field));#else src/openvpn/options.c +9
-4@@ -2712,18 +2712,23 @@ options_postprocess_verify_ce(const struct options *options,else {#ifdef ENABLE_CRYPTO_MBEDTLS -if (!(options->ca_file)) +if (!(options->ca_file || options->verify_hash_no_ca)) { -msg (M_USAGE ,"You must define CA file (--ca)" ); +msg (M_USAGE ,"You must define CA file (--ca) and/or " +"peer fingeprint verification " +"(--peer-fingerprint)" ); }if (options->ca_path) {msg (M_USAGE ,"Parameter --capath cannot be used with the mbed TLS version version of OpenVPN." ); }#else /* ifdef ENABLE_CRYPTO_MBEDTLS */ -if ((!(options->ca_file)) && (!(options->ca_path))) +if ((!(options->ca_file)) && (!(options->ca_path)) + && (!(options->verify_hash_no_ca))) { -msg (M_USAGE ,"You must define CA file (--ca) or CA path (--capath)" ); +msg (M_USAGE ,"You must define CA file (--ca) or CA path " +"(--capath) and/or peer fingeprint verification " +"(--peer-fingerprint)" ); }#endif if (pull)
src/openvpn/options.c options_postprocess_verify_ce(const struct options *options, · line 2751
Quoted 6 lines
src/openvpn/options.c +2
-1@@ -2742,7 +2747,8 @@ options_postprocess_verify_ce(const struct options *options,#if P2MP if (!options->auth_user_pass_file)#endif -msg (M_USAGE ,"No client-side authentication method is specified. You must use either --cert/--key, --pkcs12, or --auth-user-pass" ); +msg (M_USAGE ,"No client-side authentication method is specified. You must use either --cert/--key," +" --pkcs12, or --auth-user-pass" );
This seems an unrelated change?
Quoted 48 lines
src/openvpn/options.c +12
-2}else if (sum ==2 ) {@@ -3206,6 +3212,13 @@ options_postprocess_mutate(struct options *o) options_postprocess_http_proxy_override(o); }#endif +if (!o->ca_file && !o->ca_path && o->verify_hash + && o->verify_hash_depth ==0 ) + { +msg (M_INFO ,"Using certificate fingerprint to verify peer (no CA " +"option set). " ); + o->verify_hash_no_ca = true; + }#if P2MP /* @@ -3441,8 +3454,11 @@ options_postprocess_filechecks(struct options *options) errs |=check_file_access_inline (options->dh_file_inline,CHKACC_FILE , options->dh_file,R_OK ,"--dh" ); - errs |=check_file_access_inline (options->ca_file_inline,CHKACC_FILE , - options->ca_file,R_OK ,"--ca" ); +if (!options->verify_hash_no_ca) + { + errs |=check_file_access_inline (options->ca_file_inline,CHKACC_FILE , + options->ca_file,R_OK ,"--ca" ); + } errs |=check_file_access_chroot (options->chroot_dir,CHKACC_FILE , options->ca_path,R_OK ,"--capath" );src/openvpn/options.h +1
-0@@ -561,6 +561,7 @@ struct optionsstruct verify_hash_list *verify_hash;hash_algo_type verify_hash_algo;int verify_hash_depth; +bool verify_hash_no_ca;unsigned int ssl_flags;/* set to SSLF_x flags from ssl.h */ #ifdef ENABLE_PKCS11 src/openvpn/ssl.c +0
-0
src/openvpn/ssl.c init_ssl(const struct options *options, struct tls_root_ctx *new_ctx) · line 685
Quoted 5 lines
src/openvpn/ssl.c +1
-1@@ -682,7 +682,7 @@ init_ssl(const struct options *options, struct tls_root_ctx *new_ctx) }#endif -if (options->ca_file || options->ca_path) +if ((!options->verify_hash_no_ca && options->ca_file) || options->ca_path)
I don't think it is possible to have the following holding true at the same time:
1) ca_file != NULL
2) options->verify_hash_no_ca == true
If 2 is true, then 1 must be false.
For this reason I believe this if condition does not need to be modified.
Or am I missing some corner case?
Quoted 49 lines
src/openvpn/ssl.c +0
-0{tls_ctx_load_ca (new_ctx, options->ca_file, options->ca_file_inline, options->ca_path, options->tls_server);src/openvpn/ssl_common.h +1
-0@@ -285,6 +285,7 @@ struct tls_optionsconst char *remote_cert_eku;struct verify_hash_list *verify_hash;int verify_hash_depth; +bool verify_hash_no_ca;hash_algo_type verify_hash_algo;#ifdef ENABLE_X509ALTUSERNAME char *x509_username_field[MAX_PARMS ];src/openvpn/ssl_verify_mbedtls.c +17
-0@@ -62,6 +62,23 @@ verify_callback(void *session_obj, mbedtls_x509_crt *cert, int cert_depth,struct buffer cert_fingerprint =x509_get_sha256_fingerprint (cert, &gc);cert_hash_remember (session, cert_depth, &cert_fingerprint); + +if (session->opt->verify_hash_no_ca) + { +/* +* If we decide to verify the peer certificate based on the fingerprint +* we ignore wrong dates and the certificate not being trusted. +* Any other problem with the certificate (wrong key, bad cert,...) +* will still trigger an error. +* Clearing these flags relies on verify_cert will later rejecting a +* certificate that has no matching fingerprint. +*/ +uint32_t flags_ignore =MBEDTLS_X509_BADCERT_NOT_TRUSTED + |MBEDTLS_X509_BADCERT_EXPIRED + |MBEDTLS_X509_BADCERT_FUTURE ; + *flags = *flags & ~flags_ignore; + } +/* did peer present cert which was signed by our root cert? */ if (*flags !=0 ) {src/openvpn/ssl_verify_openssl.c +0
-0
src/openvpn/ssl_verify_openssl.c verify_callback(int preverify_ok, X509_STORE_CTX *ctx) · line 73
Quoted 8 lines
src/openvpn/ssl_verify_openssl.c +1
-1@@ -67,7 +67,7 @@ verify_callback(int preverify_ok, X509_STORE_CTX *ctx)cert_hash_remember (session,X509_STORE_CTX_get_error_depth (ctx), &cert_hash);/* did peer present cert which was signed by our root cert? */ -if (!preverify_ok) +if (!preverify_ok && !session->opt->verify_hash_no_ca) {/* get the X509 name */ char *subject =x509_get_subject (current_cert, &gc);
The rest looks good.
It's very nice to be able to start openvpn without CA, especially in very small setups where a couple of certs can just be enough :)
Cheers,
Signature · 1 line
Antonio Quartulli
Re: [Openvpn-devel] [PATCH v2 5/5] Deprecate the --verify-hash option
In reply to Arne SchwabeHi,
Quoted 11 lines · Arne Schwabe
Despite trying to figure out with multiple people what the use case for this option is, we could not come up with a good one. Checking that only a specific CA is used can be also done by only using that CA in the --ca directive.
Although it feels a bit strange to deprecate the option after improving it with peer-fingerprint patches, all the improvements are needed for --peer-fingerprint and making them specify to --peer-fingerprint would have added more (unecessary) changes.
Signed-off-by Arne Schwabe <[email protected]...>
This patch looks good to me, but it does not apply on top of the previous 4. Maybe it was committed without considering the old 4/4?
Regards,
Signature · 1 line
Antonio Quartulli
Re: [Openvpn-devel] [PATCH v2 5/5] Deprecate the --verify-hash option
Am 21.03.21 um 18:22 schrieb Antonio Quartulli:
Quoted 13 lines
Hi,
Quoted 10 lines · Arne Schwabe
Despite trying to figure out with multiple people what the use case for this option is, we could not come up with a good one. Checking that only a specific CA is used can be also done by only using that CA in the --ca directive.
Although it feels a bit strange to deprecate the option after improving it with peer-fingerprint patches, all the improvements are needed for --peer-fingerprint and making them specify to --peer-fingerprint would have added more (unecessary) changes.
Quoted 5 lines
Quoted 1 line
Signed-off-by Arne Schwabe <[email protected]...>This patch looks good to me, but it does not apply on top of the previous 4. Maybe it was committed without considering the old 4/4?
This patch conflicts since the grammar in the previous patch was fixed. If there is nothing else wrong with it I can resend a rebased v3.
Arne
Your patch has been applied to the master branch.
I have not really tested it, but stared a bit at code and documentation, and done a basic t_client test. Haven't set up anything that could thoroughly test this (yet!).
As discussed on IRC, I have removed the "return NULL" as suggested, and there will be a cleanup patch to fix this function for good.
commit d1fe6d52ca066ec2d49712081d5056825c8973b2
Author: Arne Schwabe Date: Sun Mar 21 15:25:38 2021 +0100
Extend verify-hash to allow multiple hashes
Signed-off-by: Arne Schwabe <[email protected]...>
Acked-by: Antonio Quartulli <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/search?l=mid&[email protected]...
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
[Openvpn-devel] [PATCH applied] Re: Implement peer-fingerprint to check fingerprint of peer certificate
In reply to Arne SchwabeYour patch has been applied to the master branch.
I have moved the Changes.rst hunk to the "new in 2.6" section, as my time machine is broken and this won't make 2.5.1 anymore :-)
I have not tested this feature itself, just stared at the code + docs (seems to make sense) and ran the client side tests (fine). A real test setup will have to be built.
commit c3a7065d5bec0ca4ad479e27c124e74fbd7c2234
Author: Arne Schwabe Date: Sun Mar 21 15:33:53 2021 +0100
Implement peer-fingerprint to check fingerprint of peer certificate
Signed-off-by: Arne Schwabe <[email protected]...>
Acked-by: Antonio Quartulli <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/search?l=mid&[email protected]...
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
Re: [Openvpn-devel] [PATCH v2 5/5] Deprecate the --verify-hash option
In reply to Arne SchwabeHi,
Quoted 2 lines · Arne Schwabe
This patch conflicts since the grammar in the previous patch was fixed. If there is nothing else wrong with it I can resend a rebased v3.
That was it. Feel free to send v3.
Cheers,
Signature · 1 line
Antonio Quartulli
PATCH v3 3/5 Support fingerprint authentication without CA certificate
In reply to Arne SchwabeFrom: "Jason A. Donenfeld" <[email protected]...>
OpenVPN traditionally works around CAs. However many TLS-based protocols also allow an alternative simpler mode in which rather than verify certificates against CAs, the certificate itself is hashed and compared against a pre-known set of acceptable hashes. This is usually referred to as "fingerprint verification". It's popular across SMTP servers, IRC servers, XMPP servers, and even in the context of HTTP with pinning.
* Allow not specifying the --ca parameter, to specify that certificates should not be checked against a CA.
I've included some instructions on how to use all of this.
Server side:
============
Make self-signed cert:
$ openssl req -x509 -newkey ec:<(openssl ecparam -name secp384r1) -keyout serverkey.pem -out servercert.pem -nodes -sha256 -days 3650 -subj '/CN=server'
Record our fingerprint in an environment variable for the client to use later:
$ server_fingerprint="$(openssl x509 -in servercert.pem -noout -sha256 -fingerprint | sed 's/.*=//;s/\(.*\)/\1/')"
Client side:
============
Make self-signed cert:
$ openssl req -x509 -newkey ec:<(openssl ecparam -name secp384r1) -keyout clientkey.pem -out clientcert.pem -nodes -sha256 -days 3650 -subj '/CN=client'
Record our fingerprint in an environment variable for the server to use later:
$ client_fingerprint="$(openssl x509 -in clientcert.pem -noout -sha256 -fingerprint | sed 's/.*=//;s/\(.*\)/\1/')"
Start server/client
===================
Start openvpn with peer fingerprint verification:
$ sudo openvpn --server 10.66.0.0 255.255.255.0 --dev tun --dh none --cert servercert.pem --key serverkey.pem --peer-fingerprint "$client_fingerprint"
$ sudo openvpn --client --remote 127.0.0.1 --dev tun --cert clientcert.pem --key clientkey.pem --peer-fingerprint "$server_fingerprint" --nobind
Patch V2: Changes in V2 (by Arne Schwabe):
- Only check peer certificates, not all cert levels, if you need multiple levels of certificate you should use a real CA
- Use peer-fingerprint instead tls-verify on server side in example.
- rename variable ca_file_none to verify_hash_no_ca
- do no require --ca none but allow --ca simply
to be absent when --peer-fingprint is present
- adjust warnings/errors messages to also point to peer-fingerprint as valid verification method.
- Fix mbed TLS version of not requiring CA
not working
Patch v3: Fix minor style. Remove unessary check of verify_hash_no_ca in ssl.c.
--- src/openvpn/init.c | 1 + src/openvpn/options.c | 27 +++++++++++++++++++++------ src/openvpn/options.h | 1 + src/openvpn/ssl_common.h | 1 + src/openvpn/ssl_verify_mbedtls.c | 16 ++++++++++++++++ src/openvpn/ssl_verify_openssl.c | 2 +- 6 files changed, 41 insertions(+), 7 deletions(-)
src/openvpn/init.c +1 -0
@@ -2928,6 +2928,7 @@ do_init_crypto_tls(struct context *c, const unsigned int flags) to.verify_hash = options->verify_hash; to.verify_hash_algo = options->verify_hash_algo; to.verify_hash_depth = options->verify_hash_depth; + to.verify_hash_no_ca = options->verify_hash_no_ca;#ifdef ENABLE_X509ALTUSERNAME memcpy (to.x509_username_field, options->x509_username_field,sizeof (to.x509_username_field));#else
src/openvpn/options.c +21 -6
@@ -2711,18 +2711,23 @@ options_postprocess_verify_ce(const struct options *options,else {#ifdef ENABLE_CRYPTO_MBEDTLS -if (!(options->ca_file)) +if (!(options->ca_file || options->verify_hash_no_ca)) { -msg (M_USAGE ,"You must define CA file (--ca)" ); +msg (M_USAGE ,"You must define CA file (--ca) and/or " +"peer fingeprint verification " +"(--peer-fingerprint)" ); }if (options->ca_path) {msg (M_USAGE ,"Parameter --capath cannot be used with the mbed TLS version version of OpenVPN." ); }#else /* ifdef ENABLE_CRYPTO_MBEDTLS */ -if ((!(options->ca_file)) && (!(options->ca_path))) +if ((!(options->ca_file)) && (!(options->ca_path)) + && (!(options->verify_hash_no_ca))) { -msg (M_USAGE ,"You must define CA file (--ca) or CA path (--capath)" ); +msg (M_USAGE ,"You must define CA file (--ca) or CA path " +"(--capath) and/or peer fingeprint verification " +"(--peer-fingerprint)" ); }#endif if (pull)
@@ -3205,6 +3210,13 @@ options_postprocess_mutate(struct options *o) options_postprocess_http_proxy_override(o); }#endif +if (!o->ca_file && !o->ca_path && o->verify_hash + && o->verify_hash_depth ==0 ) + { +msg (M_INFO ,"Using certificate fingerprint to verify peer (no CA " +"option set). " ); + o->verify_hash_no_ca = true; + }#if P2MP /*
@@ -3440,8 +3452,11 @@ options_postprocess_filechecks(struct options *options) errs |=check_file_access_inline (options->dh_file_inline,CHKACC_FILE , options->dh_file,R_OK ,"--dh" ); - errs |=check_file_access_inline (options->ca_file_inline,CHKACC_FILE , - options->ca_file,R_OK ,"--ca" ); +if (!options->verify_hash_no_ca) + { + errs |=check_file_access_inline (options->ca_file_inline,CHKACC_FILE , + options->ca_file,R_OK ,"--ca" ); + } errs |=check_file_access_chroot (options->chroot_dir,CHKACC_FILE , options->ca_path,R_OK ,"--capath" );
src/openvpn/options.h +1 -0
@@ -561,6 +561,7 @@ struct optionsstruct verify_hash_list *verify_hash;hash_algo_type verify_hash_algo;int verify_hash_depth; +bool verify_hash_no_ca;unsigned int ssl_flags;/* set to SSLF_x flags from ssl.h */ #ifdef ENABLE_PKCS11
src/openvpn/ssl_common.h +1 -0
@@ -285,6 +285,7 @@ struct tls_optionsconst char *remote_cert_eku;struct verify_hash_list *verify_hash;int verify_hash_depth; +bool verify_hash_no_ca;hash_algo_type verify_hash_algo;#ifdef ENABLE_X509ALTUSERNAME char *x509_username_field[MAX_PARMS ];
src/openvpn/ssl_verify_mbedtls.c +16 -0
@@ -62,6 +62,22 @@ verify_callback(void *session_obj, mbedtls_x509_crt *cert, int cert_depth,struct buffer cert_fingerprint =x509_get_sha256_fingerprint (cert, &gc);cert_hash_remember (session, cert_depth, &cert_fingerprint); +if (session->opt->verify_hash_no_ca) + { +/* +* If we decide to verify the peer certificate based on the fingerprint +* we ignore wrong dates and the certificate not being trusted. +* Any other problem with the certificate (wrong key, bad cert,...) +* will still trigger an error. +* Clearing these flags relies on verify_cert will later rejecting a +* certificate that has no matching fingerprint. +*/ +uint32_t flags_ignore =MBEDTLS_X509_BADCERT_NOT_TRUSTED + |MBEDTLS_X509_BADCERT_EXPIRED + |MBEDTLS_X509_BADCERT_FUTURE ; + *flags = *flags & ~flags_ignore; + } +/* did peer present cert which was signed by our root cert? */ if (*flags !=0 ) {
src/openvpn/ssl_verify_openssl.c +1 -1
@@ -67,7 +67,7 @@ verify_callback(int preverify_ok, X509_STORE_CTX *ctx)cert_hash_remember (session,X509_STORE_CTX_get_error_depth (ctx), &cert_hash);/* did peer present cert which was signed by our root cert? */ -if (!preverify_ok) +if (!preverify_ok && !session->opt->verify_hash_no_ca) {/* get the X509 name */ char *subject =x509_get_subject (current_cert, &gc);
Signature · 1 line
2.30.1
PATCH v3 5/5 Deprecate the --verify-hash option
In reply to Arne SchwabeDespite trying to figure out with multiple people what the use case for this option is, we could not come up with a good one. Checking that only a specific CA is used can be also done by only using that CA in the --ca directive.
Although it feels a bit strange to deprecate the option after improving it with peer-fingerprint patches, all the improvements are needed for --peer-fingerprint and making them specify to --peer-fingerprint would have added more (unecessary) changes.
Patch v3: rebased on v3 version of other patches.
--- Changes.rst | 3 +++ doc/man-sections/tls-options.rst | 2 +- src/openvpn/options.c | 5 +++-- 3 files changed, 7 insertions(+), 3 deletions(-)
Changes.rst +3 -0
@@ -32,6 +32,9 @@ Deprecated features This was a very limited and not-well-tested way to run OpenVPN, on TCP and TAP mode only. +``verify-hash`` has been deprecated + This option has very limited usefulness and should be replaced by either + a better ``--ca`` configuration or with a ``--tls-verify`` script. Overview of changes in 2.5 ==========================
doc/man-sections/tls-options.rst +1 -1
@@ -564,7 +564,7 @@ certificates and keys: https://github.com/OpenVPN/easy-rsa :code:`1.2`. --verify-hash args - Specify SHA1 or SHA256 fingerprint for level-1 cert. + **DEPRECATED** Specify SHA1 or SHA256 fingerprint for level-1 cert. Valid syntax: ::
src/openvpn/options.c +3 -2
@@ -8140,6 +8140,9 @@ add_option(struct options *options,int verify_hash_depth =0 ;if (streq (p[0 ],"verify-hash" )) { +msg (M_WARN ,"DEPRECATED OPTION: The option --verify-hash is deprecated. " +"You should switch to the either use the level 1 certificate as " +"--ca option, use --tls-verify or use --peer-fingerprint" );/* verify level 1 cert, i.e. the CA that signed the leaf cert */ verify_hash_depth =1 ; }
@@ -8160,8 +8163,6 @@ add_option(struct options *options,if ((!p[2 ] && !is_inline) || (p[2 ] &&streq (p[2 ],"SHA1" ))) { options->verify_hash_algo =MD_SHA1 ; -msg (M_WARN ,"DEPRECATED FEATURE: Usage of SHA1 fingerprints for " -"verify-hash is deprecated. You should switch to SHA256." ); options->verify_hash_algo =SHA_DIGEST_LENGTH ; digest_len =SHA_DIGEST_LENGTH ; }
Signature · 1 line
2.30.1
Re: [Openvpn-devel] [PATCH v3 3/5] Support fingerprint authentication without CA certificate
In reply to Arne SchwabeHi,
Quoted 54 lines · Arne Schwabe
From: "Jason A. Donenfeld" <[email protected]...>
OpenVPN traditionally works around CAs. However many TLS-based protocols also allow an alternative simpler mode in which rather than verify certificates against CAs, the certificate itself is hashed and compared against a pre-known set of acceptable hashes. This is usually referred to as "fingerprint verification". It's popular across SMTP servers, IRC servers, XMPP servers, and even in the context of HTTP with pinning.
* Allow not specifying the --ca parameter, to specify that certificates should not be checked against a CA.
I've included some instructions on how to use all of this.
Server side:
============Make self-signed cert:
$ openssl req -x509 -newkey ec:<(openssl ecparam -name secp384r1) -keyout serverkey.pem -out servercert.pem -nodes -sha256 -days 3650 -subj '/CN=server'Record our fingerprint in an environment variable for the client to use later:
$ server_fingerprint="$(openssl x509 -in servercert.pem -noout -sha256 -fingerprint | sed 's/.*=//;s/\(.*\)/\1/')"Client side:
============
Make self-signed cert:$ openssl req -x509 -newkey ec:<(openssl ecparam -name secp384r1) -keyout clientkey.pem -out clientcert.pem -nodes -sha256 -days 3650 -subj '/CN=client'Record our fingerprint in an environment variable for the server to use later:
$ client_fingerprint="$(openssl x509 -in clientcert.pem -noout -sha256 -fingerprint | sed 's/.*=//;s/\(.*\)/\1/')"Start server/client
===================Start openvpn with peer fingerprint verification:
$ sudo openvpn --server 10.66.0.0 255.255.255.0 --dev tun --dh none --cert servercert.pem --key serverkey.pem --peer-fingerprint "$client_fingerprint"$ sudo openvpn --client --remote 127.0.0.1 --dev tun --cert clientcert.pem --key clientkey.pem --peer-fingerprint "$server_fingerprint" --nobindSigned-off-by Jason A. Donenfeld <[email protected]...>Patch V2: Changes in V2 (by Arne Schwabe):
- Only check peer certificates, not all cert levels, if you need multiple levels of certificate you should use a real CA
- Use peer-fingerprint instead tls-verify on server side in example.
- rename variableca_file_nonetoverify_hash_no_ca
- do no require --ca none but allow --ca simply
to be absent when --peer-fingprint is present
- adjust warnings/errors messages to also point to peer-fingerprint as valid verification method.
- Fix mbed TLS version of not requiring CA
not working
Quoted 3 lines
Patch v3: Fix minor style. Remove unessary check of
verify_hash_no_cainssl.c.Signed-off-by Arne Schwabe <[email protected]...>
It looks good and works as expected!
Signature · 1 line
Antonio Quartulli
Re: [Openvpn-devel] [PATCH v3 5/5] Deprecate the --verify-hash option
In reply to Arne SchwabeHi,
Quoted 5 lines · Arne Schwabe
Despite trying to figure out with multiple people what the use case for this option is, we could not come up with a good one. Checking that only a specific CA is used can be also done by only using that CA in the --ca directive.
Quoted 8 lines
Although it feels a bit strange to deprecate the option after improving it with peer-fingerprint patches, all the improvements are needed for --peer-fingerprint and making them specify to --peer-fingerprint would have added more (unecessary) changes.
Patch v3: rebased on v3 version of other patches.
Signed-off-by Arne Schwabe <[email protected]...>
Signature · 1 line
Antonio Quartulli
[Openvpn-devel] [PATCH applied] Re: Support fingerprint authentication without CA certificate
In reply to Arne SchwabeYour patch has been applied to the master branch (in the reworked v3 version from Arne, but since the original idea and v1 patch are from you, we record you as the author).
I have not tested the actual functionality yet, only verified that it didn't break openssl/mbedtls builds and "regular certificate checks" (Antonio verified functionality).
commit 423ced962db3129b4ed551c489624faba4340652
Author: Jason A. Donenfeld Date: Mon Mar 22 10:14:14 2021 +0100
Support fingerprint authentication without CA certificate
Signed-off-by: Jason A. Donenfeld <[email protected]...>
Signed-off-by: Arne Schwabe <[email protected]...>
Acked-by: Antonio Quartulli <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/search?l=mid&[email protected]...
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
[Openvpn-devel] [PATCH applied] Re: Deprecate the --verify-hash option
In reply to Arne SchwabeYour patch has been applied to the master branch.
Only limited client-side testing (compile + t_client on one platform), staring-at-code suggests that no surprises are lurking.
commit 5b8a1231b90697774ae1dea98603bbbb9b5d9809
Author: Arne Schwabe Date: Mon Mar 22 10:16:21 2021 +0100
Deprecate the --verify-hash option
Signed-off-by: Arne Schwabe <[email protected]...>
Acked-by: Antonio Quartulli <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg21779.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering