Skip to contentSkip to conversation

Remove --tls-export-cert

PATCH In review David Sommerseth 2 participants 4 messages Nov 22, 2023 – Nov 23, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Remove --tls-export-cert

From: David Sommerseth <[email protected]...>

As OpenVPN 2.6+ is doing some adoptions to the license text, all prior contributors need to accept this new text. Unfortunately, Mathieu Giannecchini who implemented the --tls-export-cert feature did not respond at all. Without an explicit acceptance we need to remove this feature to avoid potential legal complications.

If this is still a wanted feature, it will need to be re-implemented from scratch.

---
 README.mbedtls                      |  1 -
 doc/man-sections/script-options.rst |  4 --
 doc/man-sections/tls-options.rst    |  7 ----
 src/openvpn/init.c                  |  1 -
 src/openvpn/options.c               | 14 -------
 src/openvpn/options.h               |  1 -
 src/openvpn/ssl_common.h            |  1 -
 src/openvpn/ssl_verify.c            | 60 +----------------------------
 8 files changed, 2 insertions(+), 87 deletions(-)
README.mbedtls +0 -1
index d3466fa9..24a9c224 100644
@@ -40,5 +40,4 @@ in the mbed TLS version of OpenVPN:
 Plugin/Script features:
 
  * X.509 subject line has a different format than the OpenSSL subject line
- * X.509 certificate export does not work
  * X.509 certificate tracking
doc/man-sections/script-options.rst +0 -4
index 8c0be0cd..38dcfa2b 100644
@@ -813,10 +813,6 @@ instances.
     translations will be recorded rather than their names as denoted on the
     command line or configuration file.
 
-:code:`peer_cert`
-    Temporary file name containing the client certificate upon connection.
-    Useful in conjunction with ``--tls-verify``.
-
 :code:`script_context`
     Set to "init" or "restart" prior to up/down script execution. For more
     information, see documentation for ``--up``.
doc/man-sections/tls-options.rst +0 -7
index d51aff77..45009f7c 100644
@@ -539,13 +539,6 @@ certificates and keys: https://github.com/OpenVPN/easy-rsa
 --tls-exit
   Exit on TLS negotiation failure.
 
---tls-export-cert directory
-  Store the certificates the clients use upon connection to this
-  directory. This will be done before ``--tls-verify`` is called. The
-  certificates will use a temporary name and will be deleted when the
-  tls-verify script returns. The file name used for the certificate is
-  available via the ``peer_cert`` environment variable.
-
 --tls-server
   Enable TLS and assume server role during TLS handshake. Note that
   OpenVPN is designed as a peer-to-peer application. The designation of
src/openvpn/init.c +0 -1
index 079c4f5e..f4ab1635 100644
@@ -3333,7 +3333,6 @@ do_init_crypto_tls(struct context *c, const unsigned int flags)
     }
 
     to.verify_command = options->tls_verify;
-    to.verify_export_cert = options->tls_export_cert;
     to.verify_x509_type = (options->verify_x509_type & 0xff);
     to.verify_x509_name = options->verify_x509_name;
     to.crl_file = options->crl_file;
src/openvpn/options.c +0 -14
index 7ca77a8e..dc18b332 100644
@@ -647,9 +647,6 @@ static const char usage_message[] =
     "                  tests of certification.  cmd should return 0 to allow\n"
     "                  TLS handshake to proceed, or 1 to fail.  (cmd is\n"
     "                  executed as 'cmd certificate_depth subject')\n"
-    "--tls-export-cert [directory] : Get peer cert in PEM format and store it \n"
-    "                  in an openvpn temporary file in [directory]. Peer cert is \n"
-    "                  stored before tls-verify script execution and deleted after.\n"
     "--verify-x509-name name: Accept connections only from a host with X509 subject\n"
     "                  DN name. The remote host must also pass all other tests\n"
     "                  of verification.\n"
@@ -1998,7 +1995,6 @@ show_settings(const struct options *o)
     SHOW_STR(cipher_list_tls13);
     SHOW_STR(tls_cert_profile);
     SHOW_STR(tls_verify);
-    SHOW_STR(tls_export_cert);
     SHOW_INT(verify_x509_type);
     SHOW_STR(verify_x509_name);
     SHOW_STR_INLINE(crl_file);
@@ -3061,7 +3057,6 @@ options_postprocess_verify_ce(const struct options *options,
         MUST_BE_UNDEF(cipher_list_tls13);
         MUST_BE_UNDEF(tls_cert_profile);
         MUST_BE_UNDEF(tls_verify);
-        MUST_BE_UNDEF(tls_export_cert);
         MUST_BE_UNDEF(verify_x509_name);
         MUST_BE_UNDEF(tls_timeout);
         MUST_BE_UNDEF(renegotiate_bytes);
@@ -4117,8 +4112,6 @@ options_postprocess_filechecks(struct options *options)
                               R_OK|W_OK, "--status");
 
     /* ** Config related ** */
-    errs |= check_file_access_chroot(options->chroot_dir, CHKACC_FILE, options->tls_export_cert,
-                                     R_OK|W_OK|X_OK, "--tls-export-cert");
     errs |= check_file_access_chroot(options->chroot_dir, CHKACC_FILE, options->client_config_dir,
                                      R_OK|X_OK, "--client-config-dir");
     errs |= check_file_access_chroot(options->chroot_dir, CHKACC_FILE, options->tmp_dir,
@@ -9001,13 +8994,6 @@ add_option(struct options *options,
                         string_substitute(p[1], ',', ' ', &options->gc),
                         "tls-verify", true);
     }
-#ifndef ENABLE_CRYPTO_MBEDTLS
-    else if (streq(p[0], "tls-export-cert") && p[1] && !p[2])
-    {
-        VERIFY_PERMISSION(OPT_P_GENERAL);
-        options->tls_export_cert = p[1];
-    }
-#endif
     else if (streq(p[0], "compat-names"))
     {
         VERIFY_PERMISSION(OPT_P_GENERAL);
src/openvpn/options.h +0 -1
index f5890b90..8e53f6f7 100644
@@ -594,7 +594,6 @@ struct options
     const char *tls_verify;
     int verify_x509_type;
     const char *verify_x509_name;
-    const char *tls_export_cert;
     const char *crl_file;
     bool crl_file_inline;
 
src/openvpn/ssl_common.h +0 -1
index 27b02947..8d8668a9 100644
@@ -335,7 +335,6 @@ struct tls_options
 
     /* cert verification parms */
     const char *verify_command;
-    const char *verify_export_cert;
     int verify_x509_type;
     const char *verify_x509_name;
     const char *crl_file;
src/openvpn/ssl_verify.c +2 -58

90 lines not on this page · raw message

Signature · 1 line
2.39.3
#1 lore raw

PATCH 1/1 Remove superfluous x509_write_pem()

From: David Sommerseth <[email protected]...>

After removing --tls-export-cert, this function was left in the code base with no other users. This was an oversight in the previous change. Removing it to avoid leaving dead code behind.

---
 src/openvpn/ssl_verify_backend.h | 11 -----------
 src/openvpn/ssl_verify_mbedtls.c |  7 -------
 src/openvpn/ssl_verify_openssl.c | 11 -----------
 3 files changed, 29 deletions(-)
src/openvpn/ssl_verify_backend.h +0 -11
index 3b798811..d402b1f2 100644
@@ -249,17 +249,6 @@ result_t x509_verify_cert_ku(openvpn_x509_cert_t *x509, const unsigned *const ex
  */
 result_t x509_verify_cert_eku(openvpn_x509_cert_t *x509, const char *const expected_oid);
 
-/*
- * Store the given certificate in pem format in a temporary file in tmp_dir
- *
- * @param cert          Certificate to store
- * @param tmp_dir       Temporary directory to store the directory
- * @param gc            gc_arena to store temporary objects in
- *
- *
- */
-result_t x509_write_pem(FILE *peercert_file, openvpn_x509_cert_t *peercert);
-
 /**
  * Return true iff a CRL is configured, but is not loaded.  This can be caused
  * by e.g. a CRL parsing error, a missing CRL file or CRL file permission
src/openvpn/ssl_verify_mbedtls.c +0 -7
index a1ddf8d0..4596843c 100644
@@ -547,13 +547,6 @@ x509_verify_cert_eku(mbedtls_x509_crt *cert, const char *const expected_oid)
     return fFound;
 }
 
-result_t
-x509_write_pem(FILE *peercert_file, mbedtls_x509_crt *peercert)
-{
-    msg(M_WARN, "mbed TLS does not support writing peer certificate in PEM format");
-    return FAILURE;
-}
-
 bool
 tls_verify_crl_missing(const struct tls_options *opt)
 {
src/openvpn/ssl_verify_openssl.c +0 -11
index 3194c232..5afffc1f 100644
@@ -762,17 +762,6 @@ x509_verify_cert_eku(X509 *x509, const char *const expected_oid)
     return fFound;
 }
 
-result_t
-x509_write_pem(FILE *peercert_file, X509 *peercert)
-{
-    if (PEM_write_X509(peercert_file, peercert) < 0)
-    {
-        msg(M_NONFATAL, "Failed to write peer certificate in PEM format");
-        return FAILURE;
-    }
-    return SUCCESS;
-}
-
 bool
 tls_verify_crl_missing(const struct tls_options *opt)
 {
Signature · 1 line
2.39.3
#2 lore raw
In reply to David Sommerseth

Hi,

Quoted 10 lines · David Sommerseth

From: David Sommerseth <[email protected]...>

As OpenVPN 2.6+ is doing some adoptions to the license text, all prior contributors need to accept this new text. Unfortunately, Mathieu Giannecchini who implemented the --tls-export-cert feature did not respond at all. Without an explicit acceptance we need to remove this feature to avoid potential legal complications.

If this is still a wanted feature, it will need to be re-implemented from scratch.

Is this significantly different from the "master" patch that it needs an extra 2.6 patch?

(So now I have 4 patches to deal with, not "1 that goes to master + release/2.6"...)

gert

Signature · 6 lines
"If was one thing all people took for granted, was conviction that if you 
 feed honest figures into a computer, honest figures come out. Never doubted 
 it myself till I met a computer with a sense of humor."
                             Robert A. Heinlein, The Moon is a Harsh Mistress

Gert Doering - Munich, Germany                             [email protected]...
#3 lore raw
Quoted 11 lines · Gert Doering

Hi,

Quoted 8 lines · David Sommerseth

From: David Sommerseth <[email protected]...>

As OpenVPN 2.6+ is doing some adoptions to the license text, all prior contributors need to accept this new text. Unfortunately, Mathieu Giannecchini who implemented the --tls-export-cert feature did not respond at all. Without an explicit acceptance we need to remove this feature to avoid potential legal complications.

Quoted 8 lines
Quoted 2 lines

If this is still a wanted feature, it will need to be re-implemented from scratch.

Is this significantly different from the "master" patch that it needs an extra 2.6 patch?

(So now I have 4 patches to deal with, not "1 that goes to master + release/2.6"...)

The "second set" should just be offset changes between master and release/2.6. I did it that way so you wouldn't need to be worried about any merge conflicts. It is based on the latest heads of master and release/2.6.

If you want to just cherry-pick the master patches for 2.6, that's all fine by me. Also if you want to squash them into a single commit as well.

These patches are purely intended to ease the merging process, as in "no conflicts expected". And to indicate that this is both master + release/2.6 material.

The main reason I overlooked the x509_write_pem() function was that Adriaan de Jong refactored out that functionality from the main feature function into a dedicated function back in the days with the SSL/TLS refactoring to support PolarSSL.

Signature · 4 lines
kind regards,

David Sommerseth
OpenVPN Inc