Bug #4885

[ext/openssl] Use BIO_reset and ERR_get_error in conjuntion

Added by Martin Bosslet almost 3 years ago. Updated almost 3 years ago.

[ruby-core:37134]
Status:Closed
Priority:Normal
Assignee:Martin Bosslet
Category:ext
Target version:1.9.3
ruby -v:trunk Backport:

Description

This is related to the bug in http://redmine.ruby-lang.org/issues/4879.

There are still some places in Ruby OpenSSL C code where just BIOreset
is used but not ERR
get_error if a fallback from PEM to DER is tried or
the other way round. This might cause encoding errors to pile up and
mislead users or cause tests to fail that shouldn't.

I'd like to expose the conjunction of

BIOreset(bio);
ERR
get_error();

as a publicly accesible macro (similar to what's in ossl_pkey.c) and
replace existing code by using it where appropriate.

Please let me know if you have any objections!

Regards,
Martin


Related issues

Related to ruby-trunk - Bug #4879: test_new(OpenSSL::TestPKeyRSA) fails on Win32 Closed 06/14/2011

Associated revisions

Revision 32199
Added by emboss almost 3 years ago

  • ext/openssl/ossl.h: Introduced OSSLBIOreset macro for PEM/DER
    fallback scenarios.

  • ext/openssl/osslpkeydsa.c

  • ext/openssl/ossl_x509req.c

  • ext/openssl/osslpkeyrsa.c

  • ext/openssl/osslpkeyec.c

  • ext/openssl/osslsslsession.c

  • ext/openssl/ossl_x509crl.c

  • ext/openssl/ossl_pkey.c

  • ext/openssl/osslpkeydh.c

  • ext/openssl/ossl_x509cert.c

  • ext/openssl/osslpkcs7.c: Use OSSLBIO_reset.

  • ext/openssl/ossl_ssl.c

  • ext/openssl/ossl_cipher.c

  • ext/openssl/osslpkeyec.c

  • ext/openssl/ossl_pkcs12.c

  • ext/openssl/osslsslsession.c: Replace rbraise occurences by
    ossl
    raise. This automatically flushes OpenSSL's error queue.

  • ext/openssl/ossl_pkcs7.c: Raise error if DER fallback for parsing
    fails.

  • test/openssl/testpkeyec.rb

  • test/openssl/testpkeydsa.rb

  • test/openssl/testpkeyrsa.rb: Add assertions that OpenSSL.errors is
    empty.

  • test/openssl/testpkeyrsa.rb: Remove initial OpenSSL.errors call in
    test_new.
    [ Ruby 1.9 - Bug #4885 ]

History

#1 Updated by Anonymous almost 3 years ago

  • Status changed from Assigned to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r32199.
Martin, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


  • ext/openssl/ossl.h: Introduced OSSLBIOreset macro for PEM/DER
    fallback scenarios.

  • ext/openssl/osslpkeydsa.c

  • ext/openssl/ossl_x509req.c

  • ext/openssl/osslpkeyrsa.c

  • ext/openssl/osslpkeyec.c

  • ext/openssl/osslsslsession.c

  • ext/openssl/ossl_x509crl.c

  • ext/openssl/ossl_pkey.c

  • ext/openssl/osslpkeydh.c

  • ext/openssl/ossl_x509cert.c

  • ext/openssl/osslpkcs7.c: Use OSSLBIO_reset.

  • ext/openssl/ossl_ssl.c

  • ext/openssl/ossl_cipher.c

  • ext/openssl/osslpkeyec.c

  • ext/openssl/ossl_pkcs12.c

  • ext/openssl/osslsslsession.c: Replace rbraise occurences by
    ossl
    raise. This automatically flushes OpenSSL's error queue.

  • ext/openssl/ossl_pkcs7.c: Raise error if DER fallback for parsing
    fails.

  • test/openssl/testpkeyec.rb

  • test/openssl/testpkeydsa.rb

  • test/openssl/testpkeyrsa.rb: Add assertions that OpenSSL.errors is
    empty.

  • test/openssl/testpkeyrsa.rb: Remove initial OpenSSL.errors call in
    test_new.
    [ Ruby 1.9 - Bug #4885 ]

Also available in: Atom PDF