Bug #6830

test failure test_constants(OpenSSL::TestConfig) [/ruby/test/openssl/test_config.rb:27] on Mac + homebrew

Added by Motohiro KOSAKI over 1 year ago. Updated over 1 year ago.

[ruby-core:46974]
Status:Closed
Priority:Normal
Assignee:Nobuyoshi Nakada
Category:ext
Target version:2.0.0
ruby -v:ruby 2.0.0dev (2012-08-04 trunk 36617) [x86_64-darwin12.0.0] Backport:

Description

When using homebrew openssl, following test failure was happen.

2) Failure:
testconstants(OpenSSL::TestConfig) [/Users/kosaki/ruby/git/test/openssl/testconfig.rb:27]:
Exception raised:
<#>.

rough analysis.

homebrew installed openssl library to "/usr/local/Cellar/openssl/1.0.1c".

and following program output "/usr/local/openssl-1.0.1c".


int main()
{
printf("%s\n", X509getdefaultcertarea());
return 0;

}

I'm using following configure options.

configure \
    --disable-install-doc \
    --with-baseruby=/usr/bin/ruby \
    --prefix=${HOME}/local/ruby-${suffix} \
    --program-suffix=-${suffix} \
--with-openssl-dir=/usr/local/Cellar/openssl/1.0.1c

So, I have several questions.

1) Is X509getdefaultcertarea() a right way to obtain configuration file?
2) If yes, is this homebrew bug?
3) if yes, should we skip this test when using Mac OS X?

Associated revisions

Revision 36666
Added by Motohiro KOSAKI over 1 year ago

  • test/openssl/testconfig.rb (OpenSSL#testconstants): skip this test if platform is Mac OS X or Windows. [Bug #6830]

History

#1 Updated by Shyouhei Urabe over 1 year ago

  • Status changed from Assigned to Feedback

Click the update button, then click "(More)". You can continue editing the description.

#2 Updated by Motohiro KOSAKI over 1 year ago

  • Description updated (diff)
  • Status changed from Feedback to Assigned

#3 Updated by Luis Lavena over 1 year ago

=begin
Hello guys,

If I can chime in, something similar happens on Windows:

https://github.com/oneclick/rubyinstaller/pull/120#issuecomment-6641054

And we workaround the issue by setting (({OPENSSL_CONF})) environment variable.

Now, I believe the root issue is not OpenSSL extension but OpenSSL itself that is using hardcoded paths.

At least Ruby tests should check if the default configuration file exists prior attempting to load it, as suggested in the RubyInstaller comment.

This issue is very common on Windows, where packages/libraries can be relocated to different drives or paths altogether, turning hardcoded paths into a problem.
=end

#4 Updated by Martin Bosslet over 1 year ago

Thanks for the detailed description! Luis has pointed out the issue on Windows to me already, and we agreed that this is probably a problem with OpenSSL itself. For quick relief, I will implement the check for the existence of the file about to be loaded and I'd also skip the test whenever it causes problems. Once done, I'll look into ways to avoid the issue with hardcoded paths altogether.

1) Is X509getdefaultcertarea() a right way to obtain configuration file?

Hmm, I'll investigate if there are better ways or alternatives.

#5 Updated by Motohiro KOSAKI over 1 year ago

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

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


  • test/openssl/testconfig.rb (OpenSSL#testconstants): skip this test if platform is Mac OS X or Windows. [Bug #6830]

#6 Updated by Usaku NAKAMURA over 1 year ago

On my Windows box, OpenSSL::Config::DEFAULTCONFIGFILE returns the right path.
So, this problem is not platform dependent but user's environment dependent.
Therefore, I can't agree r36666.

#7 Updated by Motohiro KOSAKI over 1 year ago

  • Status changed from Closed to Feedback
  • Assignee changed from Martin Bosslet to Usaku NAKAMURA

On my Windows box, OpenSSL::Config::DEFAULTCONFIGFILE returns the right path.

Which path do your OpenSSL return? I'm ok that only Mac and MinGW skip this test.

#8 Updated by Luis Lavena over 1 year ago

usa (Usaku NAKAMURA) wrote:

On my Windows box, OpenSSL::Config::DEFAULTCONFIGFILE returns the right path.
So, this problem is not platform dependent but user's environment dependent.
Therefore, I can't agree r36666.

Test is incorrect, it should check if default file exist and skip if doesn't.

On windows if you change location openssl dlls it will cause an error, as explained in the github links I've included before.

So is not a problem of platform but a hardcoded path on openssl.

Usa, can you tell us if you moved OpenSSL dlls to different directories and verified OpenSSL::Config::DEFAULTCONFIGFILE?

#9 Updated by Usaku NAKAMURA over 1 year ago

  • Status changed from Feedback to Assigned
  • Assignee changed from Usaku NAKAMURA to Motohiro KOSAKI

(1) "is not a problem of platform but a hardcoded path on openssl."
Yes, I think so, too.

(2) "if you moved OpenSSL dlls to different directories and verified OpenSSL::Config::DEFAULTCONFIGFILE?"
Of course, it fails.

So, should not skip by platform, but should determine whether to skip or not
to skip by another method, such as checking the existance of the config file,
as luis said.

#10 Updated by Motohiro KOSAKI over 1 year ago

(1) "is not a problem of platform but a hardcoded path on openssl."
Yes, I think so, too.

(2) "if you moved OpenSSL dlls to different directories and verified OpenSSL::Config::DEFAULTCONFIGFILE?"
Of course, it fails.

So, should not skip by platform, but should determine whether to skip or not
to skip by another method, such as checking the existance of the config file,
as luis said.

This test confirm OpenSSL::Config::DEFAULTCONFIGFILE correctness. Therefore,
when we skip the test if OpenSSL::Config::DEFAULTCONFIGFILE is
incorrect, it doesn't
test any meaningful thing. I just suggest to remove the test instaed
if we can't use platform
check.

#11 Updated by Nobuyoshi Nakada over 1 year ago

At least, the condition is not exact.
With MacPorts OpenSSL, the constant has a correct path.

#12 Updated by Nobuyoshi Nakada over 1 year ago

  • % Done changed from 100 to 50

#13 Updated by Motohiro KOSAKI over 1 year ago

On Fri, Aug 17, 2012 at 8:42 AM, nobu (Nobuyoshi Nakada)
nobu@ruby-lang.org wrote:

Issue #6830 has been updated by nobu (Nobuyoshi Nakada).

At least, the condition is not exact.
With MacPorts OpenSSL, the constant has a correct path.

Is there any way to detect MacPorts? I have no idea.

#14 Updated by Motohiro KOSAKI over 1 year ago

  • Status changed from Assigned to Feedback
  • Assignee changed from Motohiro KOSAKI to Nobuyoshi Nakada

#15 Updated by Nobuyoshi Nakada over 1 year ago

Now tests it if the file exists.

#16 Updated by Nobuyoshi Nakada over 1 year ago

  • Status changed from Feedback to Closed
  • % Done changed from 50 to 100

Also available in: Atom PDF