Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass pass phrase to OpenSSL::PKey::RSA. #201

Merged
merged 1 commit into from
May 21, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/httpclient/ssl_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,9 @@ def client_key=(client_key)
# use client_key=.
#
# Calling this method resets all existing sessions.
def set_client_cert_file(cert_file, key_file)
def set_client_cert_file(cert_file, key_file, pass = nil)
@client_cert = X509::Certificate.new(File.open(cert_file) { |f| f.read })
@client_key = PKey::RSA.new(File.open(key_file) { |f| f.read })
@client_key = PKey::RSA.new(File.open(key_file) { |f| f.read }, pass)
change_notify
end

Expand Down
18 changes: 18 additions & 0 deletions test/client-pass.key
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: DES-EDE3-CBC,DE0F454B166A4941

Kub+uiaDkZAmUP2P1VKKB1tPcoJ/ZSs5sLckVv156XDfH+6OilEh+E4vXuKkJnW7
KFVM/nKrKPxLtNmKha0yx2bqZeUfUdpwq1GqTve84v/oJDTOhBXPlKlkMvzzVhdC
IeJ61BgSt4ZVWSAcorae8yvDtUCtVoc0YonuiEno5bjEOWMuOu9iwviDIO+IePdY
mgIPkEyPQOY6/Ir3ImLdqmpPfVPnNxx5fIw9VXDfTqWfY3qHnGECx17ko4PCxhkN
IwnXU8E6r6XRpHV58t7JkM88eD0crpQpZ8Ki1zVPtHq8DfQLwQI+FGt6PBmeneVl
Dne6UPIaEDpd9f5X+Q7+2jZCBOsGntNh4+E7AwnG+G4IpleUG308DWsXZZpYhfLy
12WMzDlsaQ68qgO1a7rD+nOpIgUfIl7bdB242g7gWvXyVzZOGJIg/P3Fl6ydR7Al
afAQFH2L1YH7u9zJLIonMmVRz7VNUHwlVaPE18VGBbzwFOmZHj2THUUB3cOGfsC8
FgQz0JVZT5t7fAS53KRXhH/mWEimcrKSvZJxOBwoknQDtHS517wMhyUco63UYEQq
2nkW6BD08Qc92xu14hWuWrActTtsJ3wyGSPMYbqo5QRvlnpaEzaQlMRXdBHYbSFJ
D5Eo2nXXqNPX7YbyIHh+cda80r9OwmH/gvXThQd79pMvNHPZ2TWnrlZF7YAdVxHH
etLrAVas2AxXs2LdhwFTI6dmxMv92gYz/WwMeZaNV7SJ4JIKHxGCmajv12cnGVh9
qCxMIFcpISr3EMwEAnF0npfQ6Xp6rKFUXuEml036vE8=
-----END RSA PRIVATE KEY-----
2 changes: 1 addition & 1 deletion test/test_ssl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def test_verification

def test_ciphers
cfg = @client.ssl_config
cfg.set_client_cert_file(path('client.cert'), path('client.key'))
cfg.set_client_cert_file(path('client.cert'), path('client-pass.key'), 'pass4key')
cfg.add_trust_ca(path('ca.cert'))
cfg.add_trust_ca(path('subca.cert'))
cfg.timeout = 123
Expand Down