]> git.ipfire.org Git - people/ms/ipfire-2.x.git/commitdiff
openvpn: Fix verifying the certificate CN with email addresses. ovpn-verify-fix
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 15 Jun 2014 15:08:36 +0000 (17:08 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 15 Jun 2014 15:08:36 +0000 (17:08 +0200)
Reported-by: Stefan Ferstl <st.ferstl@gmail.com>
Fixes #10552:
  https://bugzilla.ipfire.org/show_bug.cgi?id=10552

config/ovpn/verify
config/ovpn/verify-test [new file with mode: 0644]
config/rootfiles/core/80/filelists/files

index 1a1fcb501d83065ca5fb408580789b993740e921..c4cbec3bd3da2fa0be846b44c60cd08c528de912 100644 (file)
@@ -30,7 +30,7 @@ my $CN    = $ARGV[1];
 exit 0 unless ($DEPTH eq "0");
 
 # Strip the CN from the X509 identifier.
-$CN =~ /(\/|,\ )CN=(.*)$/i;
+$CN =~ /(\/|,\ )CN=([^,\/ ]+)?/i;
 $CN = $2;
 
 my %confighash = ();
diff --git a/config/ovpn/verify-test b/config/ovpn/verify-test
new file mode 100644 (file)
index 0000000..42ad2ce
--- /dev/null
@@ -0,0 +1,23 @@
+#!/usr/bin/perl
+
+my @teststrings = (
+       ["ovpnClient", "C=XX, L=Xxxxxx, O=xxx, OU=XX, CN=ovpnClient, emailAddress=ovpnClient\@example.com"],
+       ["ovpnClient", "C=XX, L=Xxxxxx, O=xxx, OU=XX, CN=ovpnClient"],
+       ["ovpnClient", "C=XX/L=Xxxxxx/O=xxx/OU=XX/CN=ovpnClient/emailAddress=ovpnClient\@example.com"],
+       ["ovpnClient", "C=XX/L=Xxxxxx/O=xxx/OU=XX/CN=ovpnClient"],
+);
+
+foreach my $string (@teststrings) {
+       my $result = @$string[0];
+       my $cn     = @$string[1];
+
+       $cn =~ /(\/|,\ )CN=([^,\/ ]+)?/i;
+       $cn = $2;
+
+       if ($result eq $cn) {
+               print "GOOD: @$string\n";
+       } else {
+               print "ERROR: -->$cn<-- (@$string)\n";
+       }
+}
+
index 409e5fe8ac4e0442392c03e5efbd9d5d44e33c72..6c3001f42b5807bf162a414608368f7c46c80e23 100644 (file)
@@ -1,2 +1,3 @@
 etc/system-release
 etc/issue
+usr/lib/openvpn/verify