Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenSSL::ASN1::PrintableString#to_der raises exception #100

Closed
justahero opened this issue Aug 2, 2016 · 1 comment
Closed

OpenSSL::ASN1::PrintableString#to_der raises exception #100

justahero opened this issue Aug 2, 2016 · 1 comment
Labels

Comments

@justahero
Copy link

justahero commented Aug 2, 2016

When using an instance of the class OpenSSL::ASN1::PrintableString, it raises an IllegalArgumentException when it is encoded back to a DERPrintableString, e.g. when calling #to_der.

require 'openssl'
printable = OpenSSL::ASN1::PrintableString.new("test1234")
printable.to_der    # raises exception

This generates the following stack trace:

NativeException: java.lang.IllegalArgumentException: encoding error in getInstance: java.io.EOFException: DEF length 101 object truncated by 95
    from org.bouncycastle.asn1.DERPrintableString:-1:in `getInstance'
    from sun/reflect/NativeMethodAccessorImpl.java:-2:in `invoke0'
    from sun/reflect/NativeMethodAccessorImpl.java:62:in `invoke'
    from sun/reflect/DelegatingMethodAccessorImpl.java:43:in `invoke'
    from java/lang/reflect/Method.java:498:in `invoke'
    from org/jruby/ext/openssl/ASN1.java:693:in `typeInstance'
    from org/jruby/ext/openssl/ASN1.java:1736:in `toASN1'
    from org/jruby/ext/openssl/ASN1.java:1612:in `toDER'
    from org/jruby/ext/openssl/ASN1.java:1430:in `to_der'
    from org/jruby/ext/openssl/ASN1.java:1523:in `to_der'
    from org/jruby/ext/openssl/ASN1$Primitive$INVOKER$i$0$0$to_der.gen:-1:in `call'
    from org/jruby/runtime/callsite/CachingCallSite.java:306:in `cacheAndCall'
    from org/jruby/runtime/callsite/CachingCallSite.java:136:in `call'
    from org/jruby/ast/CallNoArgNode.java:60:in `interpret'
    from org/jruby/ast/NewlineNode.java:105:in `interpret'
    from org/jruby/ast/RootNode.java:129:in `interpret'
... 132 levels...

The same function works fine on C-Ruby and returns a String. The program above was tested with JRuby 1.7.25.

My best guess is the object that is given to the method org.bouncycastle.asn1.DERPrintableString.getInstance is not of type DERPrintableString and is handled as a byte array leading to the exception.

If you need further information or if I can be of any help, please let me know.

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/36564466-openssl-asn1-printablestring-to_der-raises-exception?utm_campaign=plugin&utm_content=tracker%2F136995&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F136995&utm_medium=issues&utm_source=github).
@kares
Copy link
Member

kares commented May 7, 2024

expected to be fixed in c3db400

@kares kares closed this as completed May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants