spec/acceptance/helpers/pkiutils.rb
# Verifies the following about a certificate file
# - Valid x509 PEM format
# - The issuer matches the CA
# - The subject matches the expected
# - The serial number is found in the CA's cert list
#
# +ca_host+:       Host object for the CA
# +ca+:            Name of the CA
# +ca_https_port+: HTTPS port to use to communicate with the CA
# +cert_host+:     Host object on which the certificate file resides
# +cert_file+:     Path to the certificate file
# +cert_subject+:  Certificate subject, excluding the 'cn=' or 'CN='
#
Verifies the following about a certificate file
Valid x509 PEM format
The issuer matches the CA
The subject matches the expected
The serial number is found in the CA's cert list


Verifies the following about a certificate file Valid x509 PEM format The issuer matches the CA The subject matches the expected The serial number is found in the CA ' s cert list
def verify_cert(ca_host, ca, ca_https_port, cert_host, cert_file, cert_subject)
         cert_text = on(cert_host, "openssl x509 -in #{cert_file} -text -noout").stdout
         expect( cert_text ).to match /Issuer: O\s*=\s*SIMP, OU\s*=\s*#{Regexp.escape(ca)}, CN\s*=\s*CA Signing Certificate/
         expect( cert_text ).to match /Subject: CN\s*=\s*#{Regexp.escape(cert_subject)}/
         match_data = cert_text.match(/Serial Number: [0-9]+ \((0[xX]{1}[0-9a-fA-F]+)\)/)
         expect( match_data ).to_not be_nil
         serial_num = match_data[1]
         expect( serial_num ).to_not be_nil
         cert_list = get_cert_list(ca_host, ca, ca_https_port)
         expect( cert_list ).to match(/Serial Number: #{serial_num}/)
      end
def verify_cert ( ca_host , ca , ca_https_port , cert_host , cert_file , cert_subject ) cert_text = on ( cert_host , "openssl x509 -in #{cert_file} -text -noout" ) . stdout expect ( cert_text ) . to match / Issuer: O \s *= \s *SIMP, OU \s *= \s * #{ Regexp . escape ( ca ) } , CN \s *= \s *CA Signing Certificate / expect ( cert_text ) . to match / Subject: CN \s *= \s * #{ Regexp . escape ( cert_subject ) } / match_data = cert_text . match ( / Serial Number: [0-9]+  \( (0[xX]{1}[0-9a-fA-F]+) \) / ) expect ( match_data ) . to_not be_nil serial_num = match_data [ 1 ] expect ( serial_num ) . to_not be_nil cert_list = get_cert_list ( ca_host , ca , ca_https_port ) expect ( cert_list ) . to match ( / Serial Number:  #{ serial_num } / ) end
Verifies the following about a certificate file
 Valid x509 PEM format
 The issuer matches the CA
 The subject matches the expected
 The serial number is found in the CA's cert list
Verifies the following about a certificate file Valid x509 PEM format The issuer matches the CA The subject matches the expected The serial number is found in the CA ' s cert list
ca_host
<not_specific>
ca
<not_specific>
ca_https_port
<not_specific>
cert_host
<not_specific>
cert_file
<not_specific>
cert_subject
<not_specific>