Skip to contentSkip to conversation

PKCS#12+additional CAs

Openvpn-devel Philipp Gühring 2 participants 2 messages Apr 19, 2006

lore
Share & tools
lore
#0 lore raw

Hi,

At the moment, openVPN is unnecessarily blocking the usage of both PKCS#12 certificate and additional CA´s provided in PEM files.
This is a patch for openVPN, to make it possible to use both PKCS#12 and additonal CA´s for verification.

PS: Please CC me on any answers.

Best regards,
Philipp Gühring

options.c renamed from options.c.orig +2 -2
@@ -1582,8 +1582,8 @@
 #endif
       if (options->pkcs12_file)
         {
-          if (options->ca_file)
-	    msg(M_USAGE, "Parameter --ca cannot be used when --pkcs12 is also specified.");
+//          if (options->ca_file)
+//	    msg(M_USAGE, "Parameter --ca cannot be used when --pkcs12 is also specified.");
           if (options->cert_file)
 	    msg(M_USAGE, "Parameter --cert cannot be used when --pkcs12 is also specified.");
           if (options->priv_key_file)
ssl.c renamed from ssl.c.orig +18 -0
@@ -842,6 +842,24 @@
                 msg (M_SSLERR, "Cannot add certificate to client CA list (SSL_CTX_add_client_CA)");
             }
         }
+
+      /* Load CA file for verifying peer supplied certificate */
+      if(options->ca_file)
+      {
+        if (!SSL_CTX_load_verify_locations (ctx, options->ca_file, NULL))
+          msg (M_SSLERR, "Cannot load CA certificate file %s (SSL_CTX_load_verify_locations)", options->ca_file);
+
+        /* Load names of CAs from file and use it as a client CA list */
+        {
+          STACK_OF(X509_NAME) *cert_names;
+          cert_names = SSL_load_client_CA_file (options->ca_file);
+          if (!cert_names)
+            msg (M_SSLERR, "Cannot load CA certificate file %s (SSL_load_client_CA_file)", options->ca_file);
+          SSL_CTX_set_client_CA_list (ctx, cert_names);
+        }
+      }
+
+
     }
   else
     {
#1 lore raw

For which version is it?

I know that version 2.1 series already support specifying trust out of the PKCS#12 file.

Best Regards,
Alon Bar-Lev.

Quoted 14 lines · Philipp Gühring

Hi,

At the moment, openVPN is unnecessarily blocking the usage of both PKCS#12 certificate and additional CA´s provided in PEM files.
This is a patch for openVPN, to make it possible to use both PKCS#12 and additonal CA´s for verification.

PS: Please CC me on any answers.

Best regards,
Philipp Gühring