Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Lots of already initialized errors from jruby-openssl #1071

Closed
bbrowning opened this Issue · 9 comments

4 participants

@bbrowning

It looks like an application with the jruby-openssl gem (ie a Rails app created under JRuby) may in some way be conflicting with the jruby-openssl shipped inside JRuby itself now.

This is with a local build of JRuby 1.7.5.dev:

$ gem install rails -v "~> 3.2.x"
$ rails new blah
$ cd blah
$ script/rails server
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant PKCS1_PADDING
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant SSLV23_PADDING
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant NO_PADDING
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant PKCS1_OAEP_PADDING
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant UNIVERSAL_TAG_NAME
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant EOC
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant BOOLEAN
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant INTEGER
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant BIT_STRING
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant OCTET_STRING
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant NULL
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant OBJECT
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant OBJECT_DESCRIPTOR
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant EXTERNAL
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant REAL
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant ENUMERATED
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant EMBEDDED_PDV
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant UTF8STRING
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant RELATIVE_OID
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant SEQUENCE
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant SET
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant NUMERICSTRING
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant PRINTABLESTRING
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant T61STRING
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant VIDEOTEXSTRING
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant IA5STRING
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant UTCTIME
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant GENERALIZEDTIME
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant GRAPHICSTRING
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant ISO64STRING
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant GENERALSTRING
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant UNIVERSALSTRING
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant CHARACTER_STRING
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant BMPSTRING
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant COMPAT
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant RFC2253
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant ONELINE
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant MULTILINE
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant DEFAULT_OBJECT_TYPE
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant OBJECT_TYPE_TEMPLATE
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant V_OK
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant V_ERR_UNABLE_TO_GET_ISSUER_CERT
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant V_ERR_UNABLE_TO_GET_CRL
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant V_ERR_CERT_SIGNATURE_FAILURE
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant V_ERR_CRL_SIGNATURE_FAILURE
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant V_ERR_CERT_NOT_YET_VALID
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant V_ERR_CERT_HAS_EXPIRED
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant V_ERR_CRL_NOT_YET_VALID
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant V_ERR_CRL_HAS_EXPIRED
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant V_ERR_OUT_OF_MEM
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant V_ERR_SELF_SIGNED_CERT_IN_CHAIN
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant V_ERR_CERT_CHAIN_TOO_LONG
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant V_ERR_CERT_REVOKED
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant V_ERR_INVALID_CA
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant V_ERR_PATH_LENGTH_EXCEEDED
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant V_ERR_INVALID_PURPOSE
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant V_ERR_CERT_UNTRUSTED
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant V_ERR_CERT_REJECTED
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant V_ERR_SUBJECT_ISSUER_MISMATCH
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant V_ERR_AKID_SKID_MISMATCH
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant V_ERR_AKID_ISSUER_SERIAL_MISMATCH
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant V_ERR_KEYUSAGE_NO_CERTSIGN
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant V_ERR_APPLICATION_VERIFICATION
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant V_FLAG_CRL_CHECK
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant V_FLAG_CRL_CHECK_ALL
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant PURPOSE_SSL_CLIENT
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant PURPOSE_SSL_SERVER
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant PURPOSE_NS_SSL_SERVER
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant PURPOSE_SMIME_SIGN
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant PURPOSE_SMIME_ENCRYPT
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant PURPOSE_CRL_SIGN
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant PURPOSE_ANY
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant PURPOSE_OCSP_HELPER
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant TRUST_COMPAT
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant TRUST_SSL_CLIENT
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant TRUST_SSL_SERVER
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant TRUST_EMAIL
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant TRUST_OBJECT_SIGN
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant TRUST_OCSP_SIGN
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant TRUST_OCSP_REQUEST
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant DEFAULT_CERT_AREA
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant DEFAULT_CERT_DIR
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant DEFAULT_CERT_FILE
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant DEFAULT_CERT_DIR_ENV
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant DEFAULT_CERT_FILE_ENV
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant DEFAULT_PRIVATE_DIR
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant Signer
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant TEXT
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant NOCERTS
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant NOSIGS
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant NOCHAIN
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant NOINTERN
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant NOVERIFY
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant DETACHED
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant BINARY
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant NOATTR
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant NOSMIMECAP
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant VERIFY_NONE
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant VERIFY_PEER
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant VERIFY_FAIL_IF_NO_PEER_CERT
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant VERIFY_CLIENT_ONCE
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant OP_ALL
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant OP_NO_TICKET
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant OP_SINGLE_ECDH_USE
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant OP_SINGLE_DH_USE
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant OP_EPHEMERAL_RSA
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant OP_CIPHER_SERVER_PREFERENCE
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant OP_TLS_ROLLBACK_BUG
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant OP_NO_SSLv2
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant OP_NO_SSLv3
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant OP_NO_TLSv1
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant OP_PKCS1_CHECK_1
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant OP_PKCS1_CHECK_2
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant OP_NETSCAPE_CA_DN_BUG
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant VERSION
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant OPENSSL_VERSION
/home/bbrowning/src/jruby/lib/ruby/shared/jruby-openssl.rb:16 warning: already initialized constant OPENSSL_VERSION_NUMBER
=> Booting WEBrick
=> Rails 3.2.14 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2013-10-01 13:56:02] INFO  WEBrick 1.3.1
[2013-10-01 13:56:02] INFO  ruby 1.9.3 (2013-10-01) [java]
[2013-10-01 13:56:02] INFO  WEBrick::HTTPServer#start: pid=21813 port=3000
@headius
Owner

By deleting lib/ruby/shared/jruby-openssl.rb I was able to start up without these issues, and I could find no references to this file anywhere in lib/. I'm wondering if bundler does an optimistic require of when is loaded, or something like that.

Can you try deleting that file and let me know if anything fails as a result? It seems like it may be a file we do not need anymore, since "openssl.rb" should trigger default gem logic or load the appropriate files in stdlib.

@atambo
Collaborator

I've been hitting this whenever I have jruby-openssl in my Gemfile. If I take it out of the Gemfile I not longer see the warnings.

@headius
Owner

Fixed by changes near d2c2d8c on master and d2c2d8c on jruby-1_7.

@headius headius closed this
@atambo
Collaborator

I don't think this is 100% fixed. I see the following when including jruby-openssl in my rails apps gemfile:

https://gist.github.com/atambo/6923891

@atambo atambo reopened this
@bruceadams

Not including "jruby-openssl" in the Gemfile works fine for ordinary rails and rake commands. But, using Warbler to package up the application and run it in a JEE server doesn't work.

org.jruby.rack.RackInitializationException: missing class or uppercase package name (`org.jruby.ext.openssl.OSSLLibrary')
    from org/jruby/javasupport/JavaUtilities.java:54:in `get_proxy_or_package_under_package'
    from classpath:/jruby/java/java_package_module_template.rb:14:in `method_missing'
    from classpath:/META-INF/jruby.home/lib/ruby/shared/openssl.rb:15:in `(root)'
    from org/jruby/RubyKernel.java:1082:in `require'

I'm working on getting coming up with a clean repeatable test that demonstrates this.

@bruceadams

For starters, this sequence (using Rails 3.2.14) gets the long list of ".../lib/jruby-openssl.rb:20 warning: already initialized constant ..." messages

rails new test-one
cd test-one
rails server
@bruceadams

Removing

gem 'jruby-openssl'

from Gemfile avoids the problem. Also, after using Warbler to package this trivial application and the application runs fine under Tomcat.

@headius
Owner

Reproduced in a Rails 4 app by adding jruby-openssl to gemfile. Investigating.

@headius headius referenced this issue from a commit
@headius headius Conditionally boot the extension only if not booted already.
Rather than using the older method for booting the jopenssl
extension, we now directly load the library. However, this does
not enlist in require logic, so it can load twice if done
unconditionally. This commit modifies that loading to only occur
if the jopenssl.jar library has not been loaded before.

Fixes #1071
e0730f8
@headius
Owner

I have pushed a fix to 1.7 and master and pushed jruby-openssl-0.9.3 gem. The gem combined with jruby-1.7.6 should fix the issue, and the gem alone might fix it too.

@headius headius closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.