Skip to content

Commit 7c18417

Browse files
committed
instead of looking of NIDs and then using X509V3_EXT_nconf_nid,
instead just pass strings to X509V3_EXT_nconf, which has all the logic for processing dealing with generic extensions also process the oid through ln2nid() to retain compatibility.
1 parent b382594 commit 7c18417

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

ext/openssl/ossl_x509ext.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -209,15 +209,16 @@ ossl_x509extfactory_create_ext(int argc, VALUE *argv, VALUE self)
209209
int nid;
210210
VALUE rconf;
211211
CONF *conf;
212+
const char *oid_cstr = NULL;
212213

213214
rb_scan_args(argc, argv, "21", &oid, &value, &critical);
214-
StringValueCStr(oid);
215215
StringValue(value);
216216
if(NIL_P(critical)) critical = Qfalse;
217217

218-
nid = OBJ_ln2nid(RSTRING_PTR(oid));
219-
if(!nid) nid = OBJ_sn2nid(RSTRING_PTR(oid));
220-
if(!nid) ossl_raise(eX509ExtError, "unknown OID `%"PRIsVALUE"'", oid);
218+
oid_cstr = StringValueCStr(oid);
219+
nid = OBJ_ln2nid(oid_cstr);
220+
if (nid != NID_undef)
221+
oid_cstr = OBJ_nid2sn(nid);
221222

222223
valstr = rb_str_new2(RTEST(critical) ? "critical," : "");
223224
rb_str_append(valstr, value);
@@ -228,7 +229,8 @@ ossl_x509extfactory_create_ext(int argc, VALUE *argv, VALUE self)
228229
rconf = rb_iv_get(self, "@config");
229230
conf = NIL_P(rconf) ? NULL : DupConfigPtr(rconf);
230231
X509V3_set_nconf(ctx, conf);
231-
ext = X509V3_EXT_nconf_nid(conf, ctx, nid, RSTRING_PTR(valstr));
232+
233+
ext = X509V3_EXT_nconf(conf, ctx, oid_cstr, RSTRING_PTR(valstr));
232234
X509V3_set_ctx_nodb(ctx);
233235
NCONF_free(conf);
234236
if (!ext){

0 commit comments

Comments
 (0)