@@ -739,26 +739,19 @@ public static void createASN1(final Ruby runtime, final RubyModule OpenSSL, fina
739
739
}
740
740
741
741
static ASN1ObjectIdentifier getObjectID (final Ruby runtime , final String nameOrOid )
742
- throws IllegalArgumentException {
742
+ throws RaiseException {
743
743
final String name = nameOrOid .toLowerCase ();
744
744
745
745
ASN1ObjectIdentifier objectId = getOIDLookup (runtime ).get ( name );
746
746
if ( objectId != null ) return objectId ;
747
747
748
748
final String objectIdStr = ASN1Registry .getOIDLookup ().get ( name );
749
- if ( objectIdStr != null ) return toObjectID (objectIdStr , false );
749
+ if ( objectIdStr != null ) return new ASN1ObjectIdentifier (objectIdStr );
750
750
751
- return new ASN1ObjectIdentifier ( nameOrOid );
752
- }
753
-
754
- static ASN1ObjectIdentifier toObjectID (final String oid , final boolean silent )
755
- throws IllegalArgumentException {
756
751
try {
757
- return new ASN1ObjectIdentifier (oid );
758
- }
759
- catch (IllegalArgumentException e ) {
760
- if ( silent ) return null ;
761
- throw e ;
752
+ return new ASN1ObjectIdentifier ( nameOrOid );
753
+ } catch (IllegalArgumentException e ) {
754
+ throw newASN1Error (runtime , "invalid OBJECT ID " + nameOrOid + ": " + e .getMessage ());
762
755
}
763
756
}
764
757
@@ -1776,17 +1769,6 @@ static void initializeImpl(final ThreadContext context,
1776
1769
// NOTE: Primitive only
1777
1770
final String baseName = self .getMetaClass ().getRealClass ().getBaseName ();
1778
1771
switch (baseName ) {
1779
- case "ObjectId" :
1780
- final String name ;
1781
- try {
1782
- name = oid2Sym ( runtime , getObjectID (runtime , value .toString ()), true );
1783
- }
1784
- catch (IllegalArgumentException e ) {
1785
- // e.g. in case of nil "string not an OID"
1786
- throw runtime .newTypeError (e .getMessage ());
1787
- }
1788
- if ( name != null ) value = runtime .newString (name );
1789
- break ;
1790
1772
case "BitString" :
1791
1773
self .setInstanceVariable ("@unused_bits" , runtime .newFixnum (0 ));
1792
1774
break ;
@@ -1858,7 +1840,9 @@ private ASN1Encodable toASN1Primitive(final ThreadContext context) {
1858
1840
1859
1841
final IRubyObject val = value (context );
1860
1842
if ( type == ASN1ObjectIdentifier .class ) {
1861
- return getObjectID (context .runtime , val .toString ());
1843
+ final String oidStr = val .convertToString ().toString ();
1844
+
1845
+ return getObjectID (context .runtime , oidStr );
1862
1846
}
1863
1847
if ( type == DERNull .class || type == ASN1Null .class ) {
1864
1848
return DERNull .INSTANCE ;
0 commit comments