Ruby Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesRuby Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old August 6th, 2010, 04:49 PM
katrash katrash is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2010
Posts: 2 katrash User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 35 m 22 sec
Reputation Power: 0
Client Certificate error on Mac OS X 10.6.4

I've been trying to connect to a web service over https where the service requires the client to be authenticated using a server signed certificate (note the server's certificate is signed from a trusted root certification authority).

The code below shows a sample that I used to test the communication (with some tweak to hide my own details). The code works OK on Windows and Linux (kernel 2.6.x) systems, but fails on Mac OS X 10.6.4 with (Timeout::Error). When I traced the wire messages I found the error is due to encryption - the server responds with Encrypted Alert = decryption_failed(21) which, acording to SSL/TLS proocol RFC2246 http://www.ietf.org/rfc/rfc2246.txt, is:
A TLSCiphertext decrypted in an invalid way: either it wasn`t an
even multiple of the block length or its padding values, when
checked, weren`t correct. This message is always fatal.

Does anyone know the cause of this error or how to fix it? Is this an error in the core Net:HTTPS and SSL core Ruby libraries specific to Mac OS X?

Code:
cer_file = File.dirname(__FILE__) + '/cert.pem'
key_file = File.dirname(__FILE__) + '/key.pem'

cert = File.read(cer_file)
key = File.read(key_file)

uri = URI.parse("https://myservice.com/servicestatus")
http = Net::HTTP.new(uri.host, uri.port)
http.open_timeout = 5
http.read_timeout = 5

http.use_ssl = (uri.scheme == "https")
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
http.cert = OpenSSL::X509::Certificate.new(cert)
http.key = OpenSSL::PKey::RSA.new(key)

http.verify_callback = Proc.new {
	puts "===> in verify_callback -- #{Time.now}"
	true
}

request = Net::HTTP::Post.new(uri.request_uri)

request.body = 
	'<?xml version="1.0" encoding="UTF-8"?>
	<env:Envelope xmlns:wsdl="http://myservice.com/ws/protocol" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
		<env:Body>
		  <wsdl:NodesListRequest>
			<AppID>MyAPP</AppID>
			<Timestamp>2010-01-01T00:00:00</Timestamp>
		  </wsdl:NodesListRequest>
		</env:Body>
	</env:Envelope>'

resp = http.request(request)
puts "response => #{resp.inspect}"


Note the same code (and same certificate and key files) works on Windows and Linux but not Mac OSX.
I tried on the Mac with Ruby 1.8.6 and 1.8.7.

Reply With Quote
  #2  
Old March 18th, 2011, 01:36 PM
dearlbry dearlbry is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2011
Posts: 1 dearlbry User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 18 m 51 sec
Reputation Power: 0
katrash,

I have a very similar issue that I traced back to OS X's stock curl library. I am using client certificates to connect to a webservice over SOAP and REST, and had this service break with an OS X update over a year ago. I was able to resolve the issue by installing macport's version of curl. However, I really don't like having to do that and was hoping you had found a solution?

David

Reply With Quote
  #3  
Old March 19th, 2011, 01:10 AM
katrash katrash is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2010
Posts: 2 katrash User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 35 m 22 sec
Reputation Power: 0
Hi David,

After posting this by about a week or so, everything started working as if has never been. The only thing I did was installing an OS X update Friday afternoon then Monday morning I discovered it was working. Since then I forgot about this issue.

I haven't found what was causing this.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesRuby Programming > Client Certificate error on Mac OS X 10.6.4

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap