-
Notifications
You must be signed in to change notification settings - Fork 113
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
IP Address SANs are invalid #69
Comments
@tsoutsman Thanks for the report! Do you have an example certificate you could share? |
Sure, the following code: use std::net::{IpAddr, Ipv4Addr};
let mut cert_params = rcgen::CertificateParams::default();
cert_params.subject_alt_names = vec![rcgen::SanType::IpAddress(IpAddr::V4(Ipv4Addr::new(
1, 2, 3, 4,
)))];
let cert = rcgen::Certificate::from_params(cert_params).unwrap();
let cert = cert.serialize_der().unwrap();
println!("{:02x?}", cert);
println!("{:#?}", simple_asn1::from_der(&cert).unwrap()); prints out the following:
I also checked with an online decoder so I don't think it's an issue in |
Upon further inspection, it seems to be an issue with a decoder. The octet string contains another sequence within it which the decoder does not realise. ASN.1 is quite the specification. Sorry for any trouble. This Stack Overflow post explains it: https://stackoverflow.com/questions/15299201/asn-1-octet-strings |
Hi,
The IP Address SAN is being encoded as an octet string of length 8 when it should be of length 4. This first four bytes are
[48, 6, 135, 4]
(decimal), irrelevant of the actual IP address. The last four bytes are the actual IP address. This seems to be related to #25, but that was fixed more than two years ago.I noticed that the
CertificateParams::write_extension
method seems to be adding the[135, 4]
bytes to the octet string. I've done very little work with ASN.1, so I might be completely missing something, especially considering no one else has recently had this issue.The text was updated successfully, but these errors were encountered: