]> xenbits.xensource.com Git - libvirt.git/commitdiff
fix regex to check CN from server certificate
authorTiago M. Vieira <tmv@redhat.com>
Fri, 26 Jan 2018 19:33:02 +0000 (14:33 -0500)
committerAndrea Bolognani <abologna@redhat.com>
Thu, 8 Feb 2018 17:05:05 +0000 (18:05 +0100)
Currently when the script validates the PKI files and
the certificate 'Subject:' field contains RDNs after
the Common Name (CN), these values are also included,
creating a false result that the CN is not correct.

A small change to the sed regex fixes this issue, by
extracting only the value for CN and nothing else. The
regex is replaced with the exact same regex used to
extract the CN value from the client certificate.

tools/virt-pki-validate.in

index 206637abf06bc4851de2b16951745a5cd1c96d3a..b04680ddef4c373f421229867644090341aa2505 100755 (executable)
@@ -255,7 +255,7 @@ then
             echo CA organization: $ORG
             echo Server organization: $S_ORG
         fi
-        S_HOST=`"$CERTOOL" -i --infile "$LIBVIRT/servercert.pem" | grep Subject: | sed 's+.*CN=\([a-zA-Z\. _-]*\)+\1+'`
+        S_HOST=`"$CERTOOL" -i --infile "$LIBVIRT/servercert.pem" | grep Subject: | sed 's+.*CN=\(.[a-zA-Z \._-]*\).*+\1+'`
         if test "$S_HOST" != "`hostname -s`" && test "$S_HOST" != "`hostname`"
         then
             echo The server certificate does not seem to match the host name