Browse code

Remove --tls-export-cert

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.

Signed-off-by: David Sommerseth <davids@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20231122143101.58483-1-dazo+openvpn@eurephia.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg27557.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>

David Sommerseth authored on 2023/11/22 23:31:01
Showing 8 changed files
... ...
@@ -38,7 +38,6 @@ in the mbed TLS version of OpenVPN:
38 38
 Plugin/Script features:
39 39
 
40 40
  * X.509 subject line has a different format than the OpenSSL subject line
41
- * X.509 certificate export does not work
42 41
  * X.509 certificate tracking
43 42
 
44 43
 *************************************************************************
... ...
@@ -813,10 +813,6 @@ instances.
813 813
     translations will be recorded rather than their names as denoted on the
814 814
     command line or configuration file.
815 815
 
816
-:code:`peer_cert`
817
-    Temporary file name containing the client certificate upon connection.
818
-    Useful in conjunction with ``--tls-verify``.
819
-
820 816
 :code:`script_context`
821 817
     Set to "init" or "restart" prior to up/down script execution. For more
822 818
     information, see documentation for ``--up``.
... ...
@@ -557,13 +557,6 @@ certificates and keys: https://github.com/OpenVPN/easy-rsa
557 557
   want to make one attempt at connecting, e.g. in a test or monitoring script.
558 558
   (OpenVPN's own test suite uses it this way.)
559 559
 
560
-  Store the certificates the clients use upon connection to this
561
-  directory. This will be done before ``--tls-verify`` is called. The
562
-  certificates will use a temporary name and will be deleted when the
563
-  tls-verify script returns. The file name used for the certificate is
564
-  available via the ``peer_cert`` environment variable.
565
-
566 560
 --tls-server
567 561
   Enable TLS and assume server role during TLS handshake. Note that
568 562
   OpenVPN is designed as a peer-to-peer application. The designation of
... ...
@@ -3302,7 +3302,6 @@ do_init_crypto_tls(struct context *c, const unsigned int flags)
3302 3302
     }
3303 3303
 
3304 3304
     to.verify_command = options->tls_verify;
3305
-    to.verify_export_cert = options->tls_export_cert;
3306 3305
     to.verify_x509_type = (options->verify_x509_type & 0xff);
3307 3306
     to.verify_x509_name = options->verify_x509_name;
3308 3307
     to.crl_file = options->crl_file;
... ...
@@ -638,9 +638,6 @@ static const char usage_message[] =
638 638
     "                  tests of certification.  cmd should return 0 to allow\n"
639 639
     "                  TLS handshake to proceed, or 1 to fail.  (cmd is\n"
640 640
     "                  executed as 'cmd certificate_depth subject')\n"
641
-    "--tls-export-cert [directory] : Get peer cert in PEM format and store it \n"
642
-    "                  in an openvpn temporary file in [directory]. Peer cert is \n"
643
-    "                  stored before tls-verify script execution and deleted after.\n"
644 641
     "--verify-x509-name name: Accept connections only from a host with X509 subject\n"
645 642
     "                  DN name. The remote host must also pass all other tests\n"
646 643
     "                  of verification.\n"
... ...
@@ -1989,7 +1986,6 @@ show_settings(const struct options *o)
1989 1989
     SHOW_STR(cipher_list_tls13);
1990 1990
     SHOW_STR(tls_cert_profile);
1991 1991
     SHOW_STR(tls_verify);
1992
-    SHOW_STR(tls_export_cert);
1993 1992
     SHOW_INT(verify_x509_type);
1994 1993
     SHOW_STR(verify_x509_name);
1995 1994
     SHOW_STR_INLINE(crl_file);
... ...
@@ -3052,7 +3048,6 @@ options_postprocess_verify_ce(const struct options *options,
3052 3052
         MUST_BE_UNDEF(cipher_list_tls13);
3053 3053
         MUST_BE_UNDEF(tls_cert_profile);
3054 3054
         MUST_BE_UNDEF(tls_verify);
3055
-        MUST_BE_UNDEF(tls_export_cert);
3056 3055
         MUST_BE_UNDEF(verify_x509_name);
3057 3056
         MUST_BE_UNDEF(tls_timeout);
3058 3057
         MUST_BE_UNDEF(renegotiate_bytes);
... ...
@@ -4108,8 +4103,6 @@ options_postprocess_filechecks(struct options *options)
4108 4108
                               R_OK|W_OK, "--status");
4109 4109
 
4110 4110
     /* ** Config related ** */
4111
-    errs |= check_file_access_chroot(options->chroot_dir, CHKACC_FILE, options->tls_export_cert,
4112
-                                     R_OK|W_OK|X_OK, "--tls-export-cert");
4113 4111
     errs |= check_file_access_chroot(options->chroot_dir, CHKACC_FILE, options->client_config_dir,
4114 4112
                                      R_OK|X_OK, "--client-config-dir");
4115 4113
     errs |= check_file_access_chroot(options->chroot_dir, CHKACC_FILE, options->tmp_dir,
... ...
@@ -9005,13 +8998,6 @@ add_option(struct options *options,
9005 9005
                         string_substitute(p[1], ',', ' ', &options->gc),
9006 9006
                         "tls-verify", true);
9007 9007
     }
9008
-#ifndef ENABLE_CRYPTO_MBEDTLS
9009
-    else if (streq(p[0], "tls-export-cert") && p[1] && !p[2])
9010
-    {
9011
-        VERIFY_PERMISSION(OPT_P_GENERAL);
9012
-        options->tls_export_cert = p[1];
9013
-    }
9014
-#endif
9015 9008
     else if (streq(p[0], "compat-names"))
9016 9009
     {
9017 9010
         VERIFY_PERMISSION(OPT_P_GENERAL);
... ...
@@ -594,7 +594,6 @@ struct options
594 594
     const char *tls_verify;
595 595
     int verify_x509_type;
596 596
     const char *verify_x509_name;
597
-    const char *tls_export_cert;
598 597
     const char *crl_file;
599 598
     bool crl_file_inline;
600 599
 
... ...
@@ -334,7 +334,6 @@ struct tls_options
334 334
 
335 335
     /* cert verification parms */
336 336
     const char *verify_command;
337
-    const char *verify_export_cert;
338 337
     int verify_x509_type;
339 338
     const char *verify_x509_name;
340 339
     const char *crl_file;
... ...
@@ -490,81 +490,25 @@ verify_cert_call_plugin(const struct plugin_list *plugins, struct env_set *es,
490 490
     return SUCCESS;
491 491
 }
492 492
 
493
-static const char *
494
-verify_cert_export_cert(openvpn_x509_cert_t *peercert, const char *tmp_dir, struct gc_arena *gc)
495
-{
496
-    FILE *peercert_file;
497
-    const char *peercert_filename = "";
498
-
499
-    /* create tmp file to store peer cert */
500
-    if (!tmp_dir
501
-        || !(peercert_filename = platform_create_temp_file(tmp_dir, "pcf", gc)))
502
-    {
503
-        msg(M_NONFATAL, "Failed to create peer cert file");
504
-        return NULL;
505
-    }
506
-
507
-    /* write peer-cert in tmp-file */
508
-    peercert_file = fopen(peercert_filename, "w+");
509
-    if (!peercert_file)
510
-    {
511
-        msg(M_NONFATAL|M_ERRNO, "Failed to open temporary file: %s",
512
-            peercert_filename);
513
-        return NULL;
514
-    }
515
-
516
-    if (SUCCESS != x509_write_pem(peercert_file, peercert))
517
-    {
518
-        msg(M_NONFATAL, "Error writing PEM file containing certificate");
519
-        (void) platform_unlink(peercert_filename);
520
-        peercert_filename = NULL;
521
-    }
522
-
523
-    fclose(peercert_file);
524
-    return peercert_filename;
525
-}
526
-
527
-
528 493
 /*
529 494
  * run --tls-verify script
530 495
  */
531 496
 static result_t
532 497
 verify_cert_call_command(const char *verify_command, struct env_set *es,
533
-                         int cert_depth, openvpn_x509_cert_t *cert, char *subject, const char *verify_export_cert)
498
+                         int cert_depth, openvpn_x509_cert_t *cert, char *subject)
534 499
 {
535
-    const char *tmp_file = NULL;
536 500
     int ret;
537 501
     struct gc_arena gc = gc_new();
538 502
     struct argv argv = argv_new();
539 503
 
540 504
     setenv_str(es, "script_type", "tls-verify");
541 505
 
542
-    if (verify_export_cert)
543
-    {
544
-        tmp_file = verify_cert_export_cert(cert, verify_export_cert, &gc);
545
-        if (!tmp_file)
546
-        {
547
-            ret = false;
548
-            goto cleanup;
549
-        }
550
-        setenv_str(es, "peer_cert", tmp_file);
551
-    }
552
-
553 506
     argv_parse_cmd(&argv, verify_command);
554 507
     argv_printf_cat(&argv, "%d %s", cert_depth, subject);
555 508
 
556 509
     argv_msg_prefix(D_TLS_DEBUG, &argv, "TLS: executing verify command");
557 510
     ret = openvpn_run_script(&argv, es, 0, "--tls-verify script");
558 511
 
559
-    if (verify_export_cert)
560
-    {
561
-        if (tmp_file)
562
-        {
563
-            platform_unlink(tmp_file);
564
-        }
565
-    }
566
-
567
-cleanup:
568 512
     gc_free(&gc);
569 513
     argv_free(&argv);
570 514
 
... ...
@@ -783,7 +727,7 @@ verify_cert(struct tls_session *session, openvpn_x509_cert_t *cert, int cert_dep
783 783
 
784 784
     /* run --tls-verify script */
785 785
     if (opt->verify_command && SUCCESS != verify_cert_call_command(opt->verify_command,
786
-                                                                   opt->es, cert_depth, cert, subject, opt->verify_export_cert))
786
+                                                                   opt->es, cert_depth, cert, subject))
787 787
     {
788 788
         goto cleanup;
789 789
     }