Ruby'nin openssl CA listesini bulmayı beklediği yeri bulmaya çalışıyorum. Benim ortamım:
- Mac OS 10.7.5
- Homebrew'den OpenSSL
- Homebrew şehrinden Rbenv
- Rbenv ve CONFIGURE_OPTS = "- with-openssl-dir =` brew --prefix openssl` " kullanılarak yüklenen Ruby 1.9.3,
Ruby'mizin homebrew OpenSSL kullandığına dair onay (not: /Users/me
aşağıdaki tüm örneklerde kullanıcı dizininin düzenlenmiş bir sürümüdür):
$ otool -L /Users/me/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/x86_64-darwin11.4.2/openssl.bundle
/Users/me/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/x86_64-darwin11.4.2/openssl.bundle:
/usr/local/opt/openssl/lib/libssl.1.0.0.dylib (compatibility version 1.0.0, current version 1.0.0)
/usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib (compatibility version 1.0.0, current version 1.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 159.1.0)
/usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)
Sınamak için aşağıdaki komut dosyasını yazdım:
#!/usr/bin/env ruby
require 'net/https'
https = Net::HTTP.new('encrypted.google.com', 443)
https.use_ssl = true
https.verify_mode = OpenSSL::SSL::VERIFY_PEER
https.request_get('/')
puts 'success!'
SSL_CERT_FILE'imin yolunu manuel olarak belirtirsem çalışır:
$ SSL_CERT_FILE=/Users/me/.rbenv/versions/1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/ssl_certs/ca-bundle.pem ./test_ssl.rb
success!
Olmazsa, kırılır:
$ ./test_ssl.rb
/Users/me/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/net/http.rb:799:in `connect': SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (OpenSSL::SSL::SSLError)
from /Users/me/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/net/http.rb:799:in `block in connect'
from /Users/me/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/timeout.rb:54:in `timeout'
from /Users/me/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/timeout.rb:99:in `timeout'
from /Users/me/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/net/http.rb:799:in `connect'
from /Users/me/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/net/http.rb:755:in `do_start'
from /Users/me/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/net/http.rb:744:in `start'
from /Users/me/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/net/http.rb:1284:in `request'
from /Users/me/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/net/http.rb:1195:in `request_get'
from ./test_ssl.rb:6:in `<main>'
Bir kenara, CA dosyası için çeşitli yolları komut dosyamdan manuel olarak kontrol edebileceğimin farkındayım. Ancak senaryo, Ruby gem "faraday" sistemimdeki benzer net / http işlemlerinin bir testidir. Bu sorun etrafında çalışmak için faraday mücevher kesmek istemiyorum.
Bu yüzden stat komutlarını aramak için dtruss kullandım ve bunlardan herhangi birine CA dosya arama denemesi yapılıp yapılmadığını kontrol ettim:
$ sudo dtruss -f -t stat64 ./test_ssl.rb
PID/THRD SYSCALL(args) = return
96741/0x6b4be4: stat64("/usr/lib/dtrace/libdtrace_dyld.dylib\0", 0x7FFF6A9BE810, 0x7FFF6A9BF700) = 0 0
96741/0x6b4be4: stat64("/usr/lib/libSystem.B.dylib\0", 0x7FFF6A9BE650, 0x7FFF6A9BF4D0) = 0 0
96741/0x6b4be4: stat64("/usr/lib/system/libcache.dylib\0", 0x7FFF6A9BE350, 0x7FFF6A9BF1D0) = 0 0
96741/0x6b4be4: stat64("/usr/lib/system/libcommonCrypto.dylib\0", 0x7FFF6A9BE350, 0x7FFF6A9BF1D0) = 0 0
96741/0x6b4be4: stat64("/usr/lib/system/libcompiler_rt.dylib\0", 0x7FFF6A9BE350, 0x7FFF6A9BF1D0) = 0 0
96741/0x6b4be4: stat64("/usr/lib/system/libcopyfile.dylib\0", 0x7FFF6A9BE350, 0x7FFF6A9BF1D0) = 0 0
96741/0x6b4be4: stat64("/usr/lib/system/libdispatch.dylib\0", 0x7FFF6A9BE350, 0x7FFF6A9BF1D0) = 0 0
96741/0x6b4be4: stat64("/usr/lib/system/libdnsinfo.dylib\0", 0x7FFF6A9BE350, 0x7FFF6A9BF1D0) = 0 0
96741/0x6b4be4: stat64("/usr/lib/system/libdyld.dylib\0", 0x7FFF6A9BE350, 0x7FFF6A9BF1D0) = 0 0
96741/0x6b4be4: stat64("/usr/lib/system/libkeymgr.dylib\0", 0x7FFF6A9BE350, 0x7FFF6A9BF1D0) = 0 0
96741/0x6b4be4: stat64("/usr/lib/system/liblaunch.dylib\0", 0x7FFF6A9BE350, 0x7FFF6A9BF1D0) = 0 0
96741/0x6b4be4: stat64("/usr/lib/system/libmacho.dylib\0", 0x7FFF6A9BE350, 0x7FFF6A9BF1D0) = 0 0
96741/0x6b4be4: stat64("/usr/lib/system/libmathCommon.A.dylib\0", 0x7FFF6A9BE350, 0x7FFF6A9BF1D0) = 0 0
96741/0x6b4be4: stat64("/usr/lib/system/libquarantine.dylib\0", 0x7FFF6A9BE350, 0x7FFF6A9BF1D0) = 0 0
96741/0x6b4be4: stat64("/usr/lib/system/libremovefile.dylib\0", 0x7FFF6A9BE350, 0x7FFF6A9BF1D0) = 0 0
96741/0x6b4be4: stat64("/usr/lib/system/libsystem_blocks.dylib\0", 0x7FFF6A9BE350, 0x7FFF6A9BF1D0) = 0 0
96741/0x6b4be4: stat64("/usr/lib/system/libsystem_c.dylib\0", 0x7FFF6A9BE350, 0x7FFF6A9BF1D0) = 0 0
96741/0x6b4be4: stat64("/usr/lib/system/libsystem_dnssd.dylib\0", 0x7FFF6A9BE350, 0x7FFF6A9BF1D0) = 0 0
96741/0x6b4be4: stat64("/usr/lib/system/libsystem_info.dylib\0", 0x7FFF6A9BE350, 0x7FFF6A9BF1D0) = 0 0
96741/0x6b4be4: stat64("/usr/lib/system/libsystem_kernel.dylib\0", 0x7FFF6A9BE350, 0x7FFF6A9BF1D0) = 0 0
96741/0x6b4be4: stat64("/usr/lib/system/libsystem_network.dylib\0", 0x7FFF6A9BE350, 0x7FFF6A9BF1D0) = 0 0
96741/0x6b4be4: stat64("/usr/lib/system/libsystem_notify.dylib\0", 0x7FFF6A9BE350, 0x7FFF6A9BF1D0) = 0 0
96741/0x6b4be4: stat64("/usr/lib/system/libsystem_sandbox.dylib\0", 0x7FFF6A9BE350, 0x7FFF6A9BF1D0) = 0 0
96741/0x6b4be4: stat64("/usr/lib/system/libunc.dylib\0", 0x7FFF6A9BE350, 0x7FFF6A9BF1D0) = 0 0
96741/0x6b4be4: stat64("/usr/lib/system/libunwind.dylib\0", 0x7FFF6A9BE350, 0x7FFF6A9BF1D0) = 0 0
96741/0x6b4be4: stat64("/usr/lib/system/libxpc.dylib\0", 0x7FFF6A9BE350, 0x7FFF6A9BF1D0) = 0 0
96741/0x6b4be4: stat64("/AppleInternal\0", 0x7FFF6A9BEFF8, 0x0) = -1 Err#2
96741/0x6b4be4: stat64("/usr/lib/libstdc++.6.dylib\0", 0x7FFF6A9BE640, 0x7FFF6A9BF4C0) = 0 0
96741/0x6b4be4: stat64("/usr/lib/libc++abi.dylib\0", 0x7FFF6A9BE550, 0x7FFF6A9BF3D0) = 0 0
Dosya istatistiklerinden hiçbiri CA dosya araması gibi gözükmüyor! Dtruss'u doğru kullanıyor muyum? CA sertifika dosyasının nereye yerleştirilmesi gerektiğini öğrenmem için başka bir yol var mı?