summaryrefslogtreecommitdiff
path: root/ext/openssl
diff options
context:
space:
mode:
authoremboss <emboss@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-02-08 04:19:33 +0000
committeremboss <emboss@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-02-08 04:19:33 +0000
commit45706e70c9e5bfefc3921c6fc406aabe83c19768 (patch)
tree395077c86a9f0209b84ed4da5c184c038728d653 /ext/openssl
parent1a991ffebcd51ffd0df80a82c2b5fe4c65f2d2c0 (diff)
* ext/openssl/ossl_x509name.c: Use the numerical representation of
unrecognized OIDs instead of the sn "UNDEF". * test/openssl/test_x509name.rb: Add tests for the fixed behavior. Patch provided by Paul Kehrer, thanḱ you! [ruby-core:41769] [Feature #5787] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34481 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/openssl')
-rw-r--r--ext/openssl/ossl_x509name.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/ext/openssl/ossl_x509name.c b/ext/openssl/ossl_x509name.c
index 13e18eecf13..247b3c724ad 100644
--- a/ext/openssl/ossl_x509name.c
+++ b/ext/openssl/ossl_x509name.c
@@ -227,10 +227,10 @@ ossl_x509name_to_a(VALUE self)
{
X509_NAME *name;
X509_NAME_ENTRY *entry;
- int i,entries;
+ int i,entries,nid;
char long_name[512];
const char *short_name;
- VALUE ary, ret;
+ VALUE ary, vname, ret;
GetX509Name(self, name);
entries = X509_NAME_entry_count(name);
@@ -246,8 +246,15 @@ ossl_x509name_to_a(VALUE self)
if (!i2t_ASN1_OBJECT(long_name, sizeof(long_name), entry->object)) {
ossl_raise(eX509NameError, NULL);
}
- short_name = OBJ_nid2sn(OBJ_ln2nid(long_name));
- ary = rb_ary_new3(3, rb_str_new2(short_name),
+ nid = OBJ_ln2nid(long_name);
+ if (nid == NID_undef) {
+ vname = rb_str_new2((const char *) &long_name);
+ } else {
+ short_name = OBJ_nid2sn(nid);
+ vname = rb_str_new2(short_name); /*do not free*/
+ }
+ ary = rb_ary_new3(3,
+ vname,
rb_str_new((const char *)entry->value->data, entry->value->length),
INT2FIX(entry->value->type));
rb_ary_push(ret, ary);