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

Parsing a CSR that has a wilcard CN with no SAN raises an exception #111

Open
Just1uke opened this issue Jul 13, 2016 · 0 comments
Open

Comments

@Just1uke
Copy link

  • What did you do?

Attempted to parse a CSR that had a wildcard as the CN, but no SAN.

  • What did you expect to happen?

Details for the CSR to be parsed out correctly.

  • What happened instead?
undefined method `value' for nil:NilClass
/gems/r509-0.10.0/lib/r509/csr.rb:204:in `block in parse_san_attribute_from_csr'"
/gems/r509-0.10.0/lib/r509/csr.rb:201:in `each'"
/gems/r509-0.10.0/lib/r509/csr.rb:201:in `parse_san_attribute_from_csr'"
/gems/r509-0.10.0/lib/r509/csr.rb:184:in `parse_csr'"
/gems/r509-0.10.0/lib/r509/csr.rb:71:in `initialize'"

Example CSR:

-----BEGIN CERTIFICATE REQUEST-----
MIICfDCCAWQCAQAwKDEUMBIGA1UEChMLVGVzdGluZyBDU1IxEDAOBgNVBAMUByou
bG9jYWwwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC/sLar/6OV6y5e
fIof69LhfOvqSaVvsic6S2FNBlPu7sC8vTl9jSo0iIxHxn2fR6hdU8IRfFAXelc4
o1pJ/x5MZF8nJk5nG1Y6+nSQCWigKqgfzAgMvIlhN786LQX0tv1UAedsLs7TWGDq
nuUbDGFJl0w7eLxSFgNLyO0+jDomsvXdjqq1tZzGeMGbbiWSRqOemWk9Qy1dmakZ
MzALvM8Kz4glDsf1LACEa6y1rdehA1HBtbcQbjynOskuFzD63kEN6Ltz0k03QYD/
TlpsfJslXy0avuihZAQIjOxgH2P+zFX9wuGICWdkLS1O81j0PApzv39RHMEmRktf
zn815pRvAgMBAAGgDzANBgkqhkiG9w0BCQ4xADANBgkqhkiG9w0BAQsFAAOCAQEA
mnxWGlARphWL8r38ndxgRUIuaDDuUnX+/JZZiskpyAm3rdEHjEalpRZMSHURnD2q
ngZkn7ljpzhuV5+JFFCLMlQ6wufD4QYKW5SNDqFvMUCwufRjW31nitGEJH/p0Lfk
wY6Br8UCWoaE+Pgs8sTcoCKG9Nf1Vk5GI3KG9YftmZlhsuv+BSM3fS4ZJ0u+SVnW
PRgbAA5vT3YstiZQclozQw4uH4srVKNIHHa1qzz5TX6PR05k0e054C8PAjZIZI/b
4XJBKLERIRFrPuqdB9R8mXRZR6F29tBv+78QTcz92/CkTNzxoDr2JbRwqR7l3gQB
nSYd3l2AB8CLsFnO1NPabQ==
-----END CERTIFICATE REQUEST-----

Code to raise exception:

cert = R509::CSR.new(csr: params[:csr].strip)

Test:

    it "works when the CN is a wildcard with no SAN" do
      csr = R509::CSR.new(:csr => @csr_wildcard_cn_no_san)
      expect(csr.subject_component('CN').to_s).to eq('*.local')
      expect(csr.san).to be_nil
    end
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

1 participant