Feature #5787 » name-fix-v2.diff
ext/openssl/ossl_x509name.c | ||
---|---|---|
int i,entries;
|
||
char long_name[512];
|
||
const char *short_name;
|
||
const char *return_name;
|
||
VALUE ary, ret;
|
||
GetX509Name(self, name);
|
||
... | ... | |
ossl_raise(eX509NameError, NULL);
|
||
}
|
||
short_name = OBJ_nid2sn(OBJ_ln2nid(long_name));
|
||
ary = rb_ary_new3(3, rb_str_new2(short_name),
|
||
if (strcmp(short_name,"UNDEF") == 0) {
|
||
return_name = &long_name;
|
||
} else {
|
||
return_name = short_name;
|
||
}
|
||
ary = rb_ary_new3(3, rb_str_new2(return_name),
|
||
rb_str_new((const char *)entry->value->data, entry->value->length),
|
||
INT2FIX(entry->value->type));
|
||
rb_ary_push(ret, ary);
|
test/openssl/test_x509name.rb | ||
---|---|---|
assert_equal(name_from_der.to_s, name.to_s)
|
||
assert_equal(name_from_der.to_a, name.to_a)
|
||
assert_equal(name_from_der.to_der, name.to_der)
|
||
dn = [
|
||
["1.2.3.4.5.6.7.8.9.7.5.3.1", "Unknown OID 1"],
|
||
["1.1.2.3.5.8.13.21.34", "Unknown OID 2"],
|
||
["C", "US"],
|
||
["postalCode", "60602"],
|
||
["ST", "Illinois"],
|
||
["L", "Chicago"],
|
||
["street", "123 Fake St"],
|
||
["O", "Some Company, LLC"],
|
||
["CN", "mydomain.com"]
|
||
]
|
||
name = OpenSSL::X509::Name.new(dn)
|
||
ary = name.to_a
|
||
assert_equal("/1.2.3.4.5.6.7.8.9.7.5.3.1=Unknown OID 1/1.1.2.3.5.8.13.21.34=Unknown OID 2/C=US/postalCode=60602/ST=Illinois/L=Chicago/street=123 Fake St/O=Some Company, LLC/CN=mydomain.com", name.to_s)
|
||
assert_equal("1.2.3.4.5.6.7.8.9.7.5.3.1", ary[0][0])
|
||
assert_equal("1.1.2.3.5.8.13.21.34", ary[1][0])
|
||
assert_equal("C", ary[2][0])
|
||
assert_equal("postalCode", ary[3][0])
|
||
assert_equal("ST", ary[4][0])
|
||
assert_equal("L", ary[5][0])
|
||
assert_equal("street", ary[6][0])
|
||
assert_equal("O", ary[7][0])
|
||
assert_equal("CN", ary[8][0])
|
||
assert_equal("Unknown OID 1", ary[0][1])
|
||
assert_equal("Unknown OID 2", ary[1][1])
|
||
assert_equal("US", ary[2][1])
|
||
assert_equal("60602", ary[3][1])
|
||
assert_equal("Illinois", ary[4][1])
|
||
assert_equal("Chicago", ary[5][1])
|
||
assert_equal("123 Fake St", ary[6][1])
|
||
assert_equal("Some Company, LLC", ary[7][1])
|
||
assert_equal("mydomain.com", ary[8][1])
|
||
end
|
||
def test_s_parse
|
- « Previous
- 1
- 2
- Next »