Merge pull request #232 from jethrogb/topic/fix_nid
Fix NID definitions to match OpenSSL.
This commit is contained in:
commit
2a4d7165f4
|
|
@ -37,6 +37,7 @@ pub enum Nid {
|
||||||
DES_EDE,
|
DES_EDE,
|
||||||
DES_EDE3,
|
DES_EDE3,
|
||||||
IDEA_CBC,
|
IDEA_CBC,
|
||||||
|
IDEA_CFB,
|
||||||
IDEA_ECB,
|
IDEA_ECB,
|
||||||
RC2_CBC,
|
RC2_CBC,
|
||||||
RC2_ECB,
|
RC2_ECB,
|
||||||
|
|
@ -55,6 +56,7 @@ pub enum Nid {
|
||||||
MessageDigest,
|
MessageDigest,
|
||||||
SigningTime,
|
SigningTime,
|
||||||
CounterSignature,
|
CounterSignature,
|
||||||
|
ChallengePassword,
|
||||||
UnstructuredAddress,
|
UnstructuredAddress,
|
||||||
ExtendedCertificateAttributes,
|
ExtendedCertificateAttributes,
|
||||||
Netscape,
|
Netscape,
|
||||||
|
|
@ -93,6 +95,7 @@ pub enum Nid {
|
||||||
AuthorityKeyIdentifier,
|
AuthorityKeyIdentifier,
|
||||||
BF_CBC,
|
BF_CBC,
|
||||||
BF_ECB,
|
BF_ECB,
|
||||||
|
BF_CFB,
|
||||||
BF_OFB,
|
BF_OFB,
|
||||||
MDC2,
|
MDC2,
|
||||||
RSA_MDC2,
|
RSA_MDC2,
|
||||||
|
|
@ -117,7 +120,8 @@ pub enum Nid {
|
||||||
RSA_SHA1_2,
|
RSA_SHA1_2,
|
||||||
DSA,
|
DSA,
|
||||||
RIPEMD160,
|
RIPEMD160,
|
||||||
RSA_RIPEMD160,
|
/* 118 missing */
|
||||||
|
RSA_RIPEMD160=119,
|
||||||
RC5_CBC,
|
RC5_CBC,
|
||||||
RC5_ECB,
|
RC5_ECB,
|
||||||
RC5_CFB,
|
RC5_CFB,
|
||||||
|
|
@ -142,7 +146,6 @@ pub enum Nid {
|
||||||
CRLReason,
|
CRLReason,
|
||||||
InvalidityDate,
|
InvalidityDate,
|
||||||
SXNetID,
|
SXNetID,
|
||||||
Pkcs12,
|
|
||||||
PBE_SHA1_RC4_128,
|
PBE_SHA1_RC4_128,
|
||||||
PBE_SHA1_RC4_40,
|
PBE_SHA1_RC4_40,
|
||||||
PBE_SHA1_3DES,
|
PBE_SHA1_3DES,
|
||||||
|
|
|
||||||
|
|
@ -69,3 +69,32 @@ fn test_subject_read_cn() {
|
||||||
|
|
||||||
assert_eq!(&cn as &str, "test_cert")
|
assert_eq!(&cn as &str, "test_cert")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_nid_values() {
|
||||||
|
let cert_path = Path::new("test/nid_test_cert.pem");
|
||||||
|
let mut file = File::open(&cert_path)
|
||||||
|
.ok()
|
||||||
|
.expect("Failed to open `test/nid_test_cert.pem`");
|
||||||
|
|
||||||
|
let cert = X509::from_pem(&mut file).ok().expect("Failed to load PEM");
|
||||||
|
let subject = cert.subject_name();
|
||||||
|
|
||||||
|
let cn = match subject.text_by_nid(Nid::CN) {
|
||||||
|
Some(x) => x,
|
||||||
|
None => panic!("Failed to read CN from cert")
|
||||||
|
};
|
||||||
|
assert_eq!(&cn as &str, "example.com");
|
||||||
|
|
||||||
|
let email = match subject.text_by_nid(Nid::Email) {
|
||||||
|
Some(x) => x,
|
||||||
|
None => panic!("Failed to read subject email address from cert")
|
||||||
|
};
|
||||||
|
assert_eq!(&email as &str, "test@example.com");
|
||||||
|
|
||||||
|
let friendly = match subject.text_by_nid(Nid::FriendlyName) {
|
||||||
|
Some(x) => x,
|
||||||
|
None => panic!("Failed to read subject friendly name from cert")
|
||||||
|
};
|
||||||
|
assert_eq!(&friendly as &str, "Example");
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
-----BEGIN CERTIFICATE-----
|
||||||
|
MIIB1DCCAX6gAwIBAgIJAMzXWZGWHleWMA0GCSqGSIb3DQEBCwUAMFYxHzAdBgkq
|
||||||
|
hkiG9w0BCQEWEHRlc3RAZXhhbXBsZS5jb20xFDASBgNVBAMMC2V4YW1wbGUuY29t
|
||||||
|
MR0wGwYJKoZIhvcNAQkUHg4ARQB4AGEAbQBwAGwAZTAeFw0xNTA3MDEwNjQ3NDRa
|
||||||
|
Fw0xNTA3MzEwNjQ3NDRaMFYxHzAdBgkqhkiG9w0BCQEWEHRlc3RAZXhhbXBsZS5j
|
||||||
|
b20xFDASBgNVBAMMC2V4YW1wbGUuY29tMR0wGwYJKoZIhvcNAQkUHg4ARQB4AGEA
|
||||||
|
bQBwAGwAZTBcMA0GCSqGSIb3DQEBAQUAA0sAMEgCQQCmejzp4+o35FD0hAnx2trL
|
||||||
|
08h07X5jZca9DgZH35hWXPh7fMucLt/IPXIRnz2zKEa/Mo6D2V/fx03Mqo0epid7
|
||||||
|
AgMBAAGjLzAtMB0GA1UdDgQWBBRQa57tXz3rZNRz+fTbo3w3jQJMBTAMBgNVHRME
|
||||||
|
BTADAQH/MA0GCSqGSIb3DQEBCwUAA0EAm0iY9cr+gvC+vcQIebdofpQ4GcDW8U6W
|
||||||
|
Bxs8ZXinLl69P0jYLum3+XITNFRiyQqcivaxdxthxDNOX7P+aKwkJA==
|
||||||
|
-----END CERTIFICATE-----
|
||||||
Loading…
Reference in New Issue