Issue #4879 has been updated by Martin Bosslet.


Thanks, Yui, for the fix!

My guess was that some uncleared error caused this
when several tests are run in sequence.

I briefly checked and there are still fallback scenarios
in Ruby OpenSSL code where something is first interpreted
as PEM and then as DER or the other way round. This way
such an error as described is put into OpenSSL's own error
queue. Most C code now uses

BIO_reset(bio);
ERR_get_error();

in conjunction now. For the those places and the remaining
code that does not yet I'd propose to expose this functionality
as a public macro and I would use it where appropriate. This
would prevent test failures as described here in the future.

What do you think?

Regards,
Martin

PS: I opened a new issue for this (http://redmine.ruby-lang.org/issues/4885)
so that the others are also aware and can intervene should they have any
doubts or objections.



----------------------------------------
Bug #4879: test_new(OpenSSL::TestPKeyRSA) fails on Win32
http://redmine.ruby-lang.org/issues/4879

Author: Akio Tajima
Status: Closed
Priority: Normal
Assignee: Martin Bosslet
Category: ext
Target version: 1.9.3
ruby -v: ruby 1.9.3dev (2011-06-13) [i386-mswin32_100]


??????????????
openssl???test_pkey_rsa.rb:48 ???fail??????????Visual C++10 ???????????????????

  1) Failure:
test_new(OpenSSL::TestPKeyRSA) [C:/Users/arton/Documents/ruby/trunk/test/openssl/test_pkey_rsa.rb:48]:
<[]> expected but was
<["error:0906D06C:PEM routines:PEM_read_bio:no start line"]>.

????????????試????????????常??????????????
?????????????????????????????????????Ruby????????????????????????????????????????????????????????????????????????
irb(main):001:0> require 'openssl'
=> true
irb(main):002:0> key = OpenSSL::PKey::RSA.new 512
=> -----BEGIN RSA PRIVATE KEY-----
MIIBOgIBAAJBAMuc7mPnOVmPweq1XMZrOZaOMVoTCX88fsU4460qF0me4S+yGL90
(??????)
-----END RSA PRIVATE KEY-----

irb(main):003:0> pem  = key.public_key.to_pem
=> "-----BEGIN PUBLIC KEY-----\nMFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAMuc7mPnOVmPweq1
XMZrOZaOMVoTCX88\nfsU4460qF0me4S+yGL902+yR5Gv2R6B4QvE5EnxGY5zD9t355+IKaQMCAwEAAQ
==\n-----END PUBLIC KEY-----\n"
irb(main):004:0> OpenSSL::PKey::RSA.new pem
=> -----BEGIN PUBLIC KEY-----
MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAMuc7mPnOVmPweq1XMZrOZaOMVoTCX88
fsU4460qF0me4S+yGL902+yR5Gv2R6B4QvE5EnxGY5zD9t355+IKaQMCAwEAAQ==
-----END PUBLIC KEY-----

irb(main):005:0> OpenSSL.errors
=> []

???????????????????test_new???????????設??????????????????????読???????????????????????次?????????test_new????????????????????????????
  def test_new
    $stderr.puts OpenSSL.errors.inspect
    $stderr.flush
    key = OpenSSL::PKey::RSA.new 512
    pem  = key.public_key.to_pem
    OpenSSL::PKey::RSA.new pem
    assert_equal([], OpenSSL.errors)
  end

??????????修正????????fail?????????????????????????????????????????以????????????????????????試????????????常????????????????????
.........................................................["error:0D07803A:asn1 e
ncoding routines:ASN1_ITEM_EX_D2I:nested asn1 error"]...(??????)

OpenSSL???1.0.0a???????

irb(main):001:0> require 'openssl'
=> true
irb(main):002:0> OpenSSL::OPENSSL_VERSION
=> "OpenSSL 1.0.0a 1 Jun 2010"

????????????????????????????


-- 
http://redmine.ruby-lang.org