Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create CSR with SANs using keytool

I'd like to ask whether it is possible to create CSR that contains SAN records.

I created keystore as

keytool -genkeypair -keyalg RSA -keysize 2048 -alias testAlias -ext SAN=dns:test.example.com -keystore test.jks -storetype JKS -dname "CN=test"

I can check using keytool, that SAN is in keystore

keytool -list -v -keystore test.jks

and relevnt part of the output is

#1: ObjectId: 2.5.29.17 Criticality=false
SubjectAlternativeName [
  DNSName: test.example.com
]

Then I created CSR using keytool:

keytool -certreq -file test.csr -keystore test.jks -alias testAlias

but in CSR there is information about SAN missing.

How to check:

keytool -printcertreq -file test.csr -v

correctly there should be something similar to

Extension Request:

#1: ObjectId: 2.5.29.17 Criticality=false
SubjectAlternativeName [
  DNSName: test.example.com
]

Did I miss some option for certreq ?

like image 933
Betlista Avatar asked Jun 10 '15 11:06

Betlista


People also ask

How do you add San while creating CSR?

A safer option for adding SAN information to an already-signed CSR is to use an enrollment agent (EA) certificate to re-sign the original request. You can then specify the correct SAN information, and re-sign the original request with the EA certificate.


1 Answers

when You generate CSR you need to specify -ext attribute again

keytool -certreq -file test.csr -keystore test.jks -alias testAlias -ext SAN=dns:test.example.com
like image 57
MrPatol Avatar answered Oct 24 '22 06:10

MrPatol