Question: TypeError when using write_smime in jruby

Question

TypeError when using write_smime in jruby

Answers 0
Added at 2016-12-14 11:12
Tags
Question

I'm trying to sign an email with the openssl library of jruby 1.7.26 and get the error "TypeError: nil is not a string".

Here is my test script:

require 'openssl'

certificate = OpenSSL::X509::Certificate.new(File.read(Rails.root.join('config', 'my-cert.crt')))
private_key = OpenSSL::PKey::RSA.new(File.read(Rails.root.join('config', 'my-key.key')))
data = "Test"
OpenSSL::PKCS7.write_smime(OpenSSL::PKCS7.sign(certificate, private_key, data, [], OpenSSL::PKCS7::DETACHED))

The error happens here:

TypeError: nil is not a string
from org/jruby/ext/openssl/PKCS7.java:197:in `write_smime'

The Input for the write_smime funtion looks like this:

#<OpenSSL::PKCS7:0xea458d5 @data="Test">

Any help with finding a solution for this error is highly appreciated.

Answers to

TypeError when using write_smime in jruby

Source Show
◀ Wstecz