Skip to contentSkip to conversation

Patch for a new tls-export-cert option

Openvpn-devel Mathieu GIANNECCHINI 1 participant 1 message Dec 6, 2005

lore
Share & tools
lore
#0 lore raw

Hello,

Here is a tiny patch which add to OpenVPN a new option "tls-export-cert" :

--tls-export-cert [directory] : Get peer cert in PEM format and store it in an openvpn temporary file in [directory]. Peer cert is stored *before* tls-verify script execution and deleted *after*. The peer cert temporary file name is send to tls-verify script by an environement variable named "peer_cert".

This new option may be usefull to add some check into tls-verify script.

For example, if you have a PKI with more than one CA, you can handle a full CRL check with -crl_check_all openssl option. Here is an example of tls-verify script :

#!/bin/sh

# All CRL are in /etc/openvpn/capath directory
RESULT=openssl verify -CApath /etc/openvpn/capath -crl_check_all -verbose $peer_cert 2>&1

# Is CRL check OK ?
echo $RESULT | grep -qE "$peer_cert: OK"
if [ $? -eq 0 ]
then
echo "openssl verify successed : $RESULT"
exit 0
fi

# CRL verification failed
exit 1

Regards,

Mat

init.c +1 -0
diff -ru openvpn-2.0.5/init.c openvpn-2.0.5-patch/init.c
@@ -1358,6 +1358,7 @@
 #endif
 
   to.verify_command = options->tls_verify;
+  to.verify_export_cert = options->tls_export_cert;
   to.verify_x509name = options->tls_remote;
   to.crl_file = options->crl_file;
   to.ns_cert_type = options->ns_cert_type;
options.c +10 -0
diff -ru openvpn-2.0.5/options.c openvpn-2.0.5-patch/options.c
@@ -432,6 +432,9 @@
   "                  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 X509_NAME_oneline')\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"
   "--tls-remote x509name: Accept connections only from a host with X509 name\n"
   "                  x509name. The remote host must also pass all other tests\n"
   "                  of verification.\n"
@@ -1114,6 +1117,7 @@
 #endif
   SHOW_STR (cipher_list);
   SHOW_STR (tls_verify);
+  SHOW_STR (tls_export_cert);
   SHOW_STR (tls_remote);
   SHOW_STR (crl_file);
   SHOW_INT (ns_cert_type);
@@ -1634,6 +1638,7 @@
       MUST_BE_UNDEF (pkcs12_file);
       MUST_BE_UNDEF (cipher_list);
       MUST_BE_UNDEF (tls_verify);
+      MUST_BE_UNDEF (tls_export_cert);
       MUST_BE_UNDEF (tls_remote);
       MUST_BE_UNDEF (tls_timeout);
       MUST_BE_UNDEF (renegotiate_bytes);
@@ -4442,6 +4447,11 @@
 	goto err;
       options->tls_verify = string_substitute (p[1], ',', ' ', &options->gc);
     }
+  else if (streq (p[0], "tls-export-cert") && p[1])
+    {
+      VERIFY_PERMISSION (OPT_P_GENERAL);
+      options->tls_export_cert = p[1];
+    }		  
   else if (streq (p[0], "tls-remote") && p[1])
     {
       ++i;
options.h +1 -0
diff -ru openvpn-2.0.5/options.h openvpn-2.0.5-patch/options.h
@@ -363,6 +363,7 @@
   const char *pkcs12_file;
   const char *cipher_list;
   const char *tls_verify;
+  const char *tls_export_cert;
   const char *tls_remote;
   const char *crl_file;
   int ns_cert_type; /* set to 0, NS_SSL_SERVER, or NS_SSL_CLIENT */
ssl.c +75 -0

98 lines not on this page · raw message

ssl.h +1 -0
diff -ru openvpn-2.0.5/ssl.h openvpn-2.0.5-patch/ssl.h
@@ -407,6 +407,7 @@
 
   /* cert verification parms */
   const char *verify_command;
+  const char *verify_export_cert;
   const char *verify_x509name;
   const char *crl_file;
   int ns_cert_type;