exit 0 unless ($DEPTH eq "0");
# Strip the CN from the X509 identifier.
-$CN =~ /(\/|,\ )CN=(.*)$/i;
+$CN =~ /(\/|,\ )CN=([^,\/ ]+)?/i;
$CN = $2;
my %confighash = ();
--- /dev/null
+#!/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";
+ }
+}
+