Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Signed certificates missing SAN names from CSR #103

Open
yonah-codefresh opened this issue May 12, 2015 · 2 comments
Open

Signed certificates missing SAN names from CSR #103

yonah-codefresh opened this issue May 12, 2015 · 2 comments

Comments

@yonah-codefresh
Copy link

Hi,

I've generated a CSR with r509 which includes several ip addresses as SAN names.
When I use r509 to sign the CSR with our CA cert, I get a certificate but the SAN names are missing. I have no idea why :?

Here is the code:

csr=R509::CSR.load_from_file(ARGF)
cert_pem = File.read("ca.pem")
key_pem = File.read("ca-key.pem")
cert = R509::Cert.new(
  :cert => cert_pem
  :key => key_pem,
  :password => "passphrase"
)
config = R509::Config::CAConfig.new(
  :ca_cert => cert
)
ca = R509::CertificateAuthority::Signer.new(config)
ext = []
ext << R509::Cert::Extensions::BasicConstraints.new(:ca => false)
cert = ca.sign(
  :csr => csr,
  :extensions => ext
)
@yonah-codefresh
Copy link
Author

Managed to fix this as follows:

ext = []
ext << R509::Cert::Extensions::BasicConstraints.new(:ca => false)
ext << R509::Cert::Extensions::SubjectAlternativeName.new(:value => csr.san)
cert = ca.sign(
  :csr => csr,
  :extensions => ext
)

It seems counter-intuitive to need to pull information manually out of the csr when signing the same csr. Is this expected behavior?

@reaperhulk
Copy link
Member

For security reasons the signer requires you to pass the set of extensions you want to sign as an argument. All extensions in the CSR are dropped if you don't explicitly copy them. Maybe we should document that more clearly?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants