@@ -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
@@ -1784,17 +1777,6 @@ static void initializeImpl(final ThreadContext context,
1784
1777
// NOTE: Primitive only
1785
1778
final String baseName = self .getMetaClass ().getRealClass ().getBaseName ();
1786
1779
switch (baseName ) {
1787
- case "ObjectId" :
1788
- final String name ;
1789
- try {
1790
- name = oid2Sym ( runtime , getObjectID (runtime , value .toString ()), true );
1791
- }
1792
- catch (IllegalArgumentException e ) {
1793
- // e.g. in case of nil "string not an OID"
1794
- throw runtime .newTypeError (e .getMessage ());
1795
- }
1796
- if ( name != null ) value = runtime .newString (name );
1797
- break ;
1798
1780
case "BitString" :
1799
1781
self .setInstanceVariable ("@unused_bits" , runtime .newFixnum (0 ));
1800
1782
break ;
@@ -1866,7 +1848,9 @@ private ASN1Encodable toASN1Primitive(final ThreadContext context) {
1866
1848
1867
1849
final IRubyObject val = value (context );
1868
1850
if ( type == ASN1ObjectIdentifier .class ) {
1869
- return getObjectID (context .runtime , val .toString ());
1851
+ final String oidStr = val .convertToString ().toString ();
1852
+
1853
+ return getObjectID (context .runtime , oidStr );
1870
1854
}
1871
1855
if ( type == DERNull .class || type == ASN1Null .class ) {
1872
1856
return DERNull .INSTANCE ;
0 commit comments