@@ -38,7 +38,8 @@ def initialize(info = {})
3838 OptPath . new ( 'PRIVKEY' , [ false , 'Sign the cert with your own CA private key' , nil ] ) ,
3939 OptString . new ( 'PRIVKEY_PASSWORD' , [ false , 'Password for private key specified in PRIV_KEY (if applicable)' , nil ] ) ,
4040 OptPath . new ( 'CA_CERT' , [ false , 'CA Public certificate' , nil ] ) ,
41- OptString . new ( 'ADD_CN' , [ false , 'Add CN to match spoofed site name (e.g. *.example.com)' , nil ] )
41+ OptString . new ( 'ADD_CN' , [ false , 'Add CN to match spoofed site name (e.g. *.example.com)' , nil ] ) ,
42+ OptString . new ( 'ADD_SAN' , [ false , 'Add SAN entries to certificate (e.g. alt.example.com,127.0.0.1)' , nil ] )
4243 ]
4344 )
4445
@@ -180,6 +181,17 @@ def run
180181 ef . create_extension ( 'subjectKeyIdentifier' , 'hash' ) ,
181182 ]
182183
184+ # Add additional SAN entries to the new cert. See https://support.f5.com/csp/article/K13471
185+ # for an example of how this added SAN field is expected to look like in a certificate.
186+ if !datastore [ 'ADD_SAN' ] . nil? && !datastore [ 'ADD_SAN' ] . empty?
187+ sans = datastore [ 'ADD_SAN' ] . to_s . split ( /,/ )
188+ sans . map! do |san |
189+ san = ( san =~ Resolv ::IPv4 ::Regex || san =~ Resolv ::IPv6 ::Regex ) ? "IP:#{ san } " : "DNS:#{ san } "
190+ end
191+ new_cert . add_extension ( ef . create_extension ( 'subjectAltName' , sans . join ( ',' ) , false ) )
192+ print_status ( "Adding #{ datastore [ 'ADD_SAN' ] } to the certificate subject alternative names" )
193+ end
194+
183195 if !datastore [ 'PRIVKEY' ] . nil? && !datastore [ 'PRIVKEY' ] . empty?
184196 new_cert . sign ( ca_key , OpenSSL ::Digest . new ( hashtype ) )
185197 new_key = ca_key # Set for file output
0 commit comments