Incomplete HTTS response from Microsoft IIS servers using net/https
-------------------------------------------------------------------

                 Key: JRUBY-1578
                 URL: http://jira.codehaus.org/browse/JRUBY-1578
             Project: JRuby
          Issue Type: Bug
          Components: Core Classes/Modules
    Affects Versions: JRuby 1.0.2
         Environment: Fedora Core 8 / Java(TM) SE Runtime Environment (build 
1.6.0_03-b05) / ruby 1.8.5 (2007-11-01 rev 4810) [i386-jruby1.0.2] / 
jruby-openssl (0.0.4)
Same observation on  Java(TM) 2 Runtime Environment, Standard Edition (build 
1.5.0_13-b05)  with other environment setting identical

CRuby MRI comparison with  ruby 1.8.6 (2007-09-24 patchlevel 111) [i386-linux]
            Reporter: Chiaming Hsu


I encounter this problem when trying to integrate with Authorize.Net payment 
gateway.  I don't have my own instance of Microsoft IIS server, so the tests 
attached use Authorized.Net public test servers.  I have run similar tests 
against my own Apache / HTTPS and there is no problem at all, so this seems to 
be IIS specific.

For the certification (test-non-production) server, the response header seems 
to load properly, but the response body always comes back empty (Test script 
and debug output below).

For the test server, the response header can not even finish loading  (Test 
script and debug output below).

These tests are repeatable and consistent.  The difference between the 
certification server and test server I observed is that test server response 
head has an extra line of  "X-Powered-By: ASP.NET".  My guess is the test 
server is running ASP.Net, and the certification sever is running plain IIS.

The same test scripts running with CRuby MRI produce proper response without 
error (debug output below also).  I have also run sample Java client provided 
by Authorized.Net against their IIS servers and that runs fine as well.  Hence, 
there is something wrong with how JRuby handles HTTPS response stream which 
cause pre-mature EOFError to be thrown when connected to IIS servers.

I set the Priority at Major since Authorized.Net is a fairly big payment 
gateway, and if this problem is not resolved, it will prevent people from using 
JRuby to create e-commerce sites.


TEST SCRIPTS AND DEBUG OUTPUT

=================================================================
TEST SCRIPT against  Authorized.Net  certification server

require 'net/https'

uri = URI.parse('https://certification.authorize.net/gateway/transact.dll')
request = Net::HTTP.new(uri.host, uri.port)
request.set_debug_output $stderr
request.use_ssl = true
response = request.post(uri.path, 'x_version=3.1')

puts 'Response Code = ' + response.code
puts 'Response Content Length = ' + response.content_length.to_s
puts 'Response Body = ' + response.body.inspect

=================================
DEBUG OUTPUT when run using JRuby

jruby https_response_eof_error_msiis_test.rb
opening connection to certification.authorize.net...
opened
warning: peer certificate won't be verified in this SSL session
<- "POST /gateway/transact.dll HTTP/1.1\r\nConnection: close\r\nContent-Type: 
application/x-www-form-urlencoded\r\nContent-Length: 13\r\nHost: 
certification.authorize.net\r\nAccept: */*\r\n\r\n"
<- "x_version=3.1"
-> "HTTP/1.1 100 Continue\r\n"
-> "Server: Microsoft-IIS/5.0\r\n"
-> "Date: Sun, 18 Nov 2007 17:48:01 GMT\r\n"
-> "\r\n"
-> "HTTP/1.1 200 OK\r\n"
-> "Server: Microsoft-IIS/5.0\r\n"
-> "Date: Sun, 18 Nov 2007 17:48:01 GMT\r\n"
-> "Connection: close\r\n"
-> "Content-Type: text/html\r\n"
-> "Content-Length: 151\r\n"
-> "\r\n"
reading 151 bytes...
-> ""
read 0 bytes
Conn close
Response Code = 200
Response Content Length = 151
Response Body = ""

=================================
DEBUG OUTPUT when run using CRuby MRI

ruby https_response_eof_error_msiis_test.rb
opening connection to certification.authorize.net...
opened
warning: peer certificate won't be verified in this SSL session
<- "POST /gateway/transact.dll HTTP/1.1\r\nConnection: close\r\nAccept: 
*/*\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length: 
13\r\nHost: certification.authorize.net\r\n\r\n"
<- "x_version=3.1"
-> "HTTP/1.1 100 Continue\r\n"
-> "Server: Microsoft-IIS/5.0\r\n"
-> "Date: Sun, 18 Nov 2007 17:48:12 GMT\r\n"
-> "\r\n"
-> "HTTP/1.1 200 OK\r\n"
-> "Server: Microsoft-IIS/5.0\r\n"
-> "Date: Sun, 18 Nov 2007 17:48:12 GMT\r\n"
-> "Connection: close\r\n"
-> "Content-Type: text/html\r\n"
-> "Content-Length: 151\r\n"
-> "\r\n"
reading 151 bytes...
-> ""
-> "<HTML><BODY><H3>The following errors have occurred."
-> "</H3>(13) The merchant login ID or password is invalid or the account is 
inactive.<BR></BODY></HTML>"
read 151 bytes
Conn close
Response Code = 200
Response Content Length = 151
Response Body = "<HTML><BODY><H3>The following errors have occurred.</H3>(13) 
The merchant login ID or password is invalid or the account is 
inactive.<BR></BODY></HTML>"

=================================================================
TEST SCRIPT against  Authorized.Net  test server

require 'net/https'

uri = URI.parse('https://test.authorize.net/gateway/transact.dll')
request = Net::HTTP.new(uri.host, uri.port)
request.set_debug_output $stderr
request.use_ssl = true
response = request.post(uri.path, 'x_version=3.1')

puts 'Response Code = ' + response.code
puts 'Response Content Length = ' + response.content_length.to_s
puts 'Response Body = ' + response.body.inspect

=================================
DEBUG OUTPUT when run using JRuby

jruby https_response_eof_error_msiis_test.rb
opening connection to test.authorize.net...
opened
warning: peer certificate won't be verified in this SSL session
<- "POST /gateway/transact.dll HTTP/1.1\r\nConnection: close\r\nContent-Type: 
application/x-www-form-urlencoded\r\nContent-Length: 13\r\nHost: 
test.authorize.net\r\nAccept: */*\r\n\r\n"
<- "x_version=3.1"
-> "HTTP/1.1 100 Continue\r\n"
-> "Server: Microsoft-IIS/5.0\r\n"
-> "Date: Sun, 18 Nov 2007 17:50:31 GMT\r\n"
-> "X-Powered-By: ASP.NET\r\n"
-> "\r\n"
-> "HTTP/1.1 200 OK\r\n"
-> "Server: Microsoft-IIS/5.0\r\n"
-> "Date: Sun, 18 Nov 2007 17:5"
-> ""
reading all...
-> ""
read 0 bytes
Conn close
Response Code = 200
Response Content Length =
Response Body = ""

=================================
DEBUG OUTPUT when run using CRuby MRI

ruby https_response_eof_error_msiis_test.rb
opening connection to test.authorize.net...
opened
warning: peer certificate won't be verified in this SSL session
<- "POST /gateway/transact.dll HTTP/1.1\r\nConnection: close\r\nAccept: 
*/*\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length: 
13\r\nHost: test.authorize.net\r\n\r\n"
<- "x_version=3.1"
-> "HTTP/1.1 100 Continue\r\n"
-> "Server: Microsoft-IIS/5.0\r\n"
-> "Date: Sun, 18 Nov 2007 17:52:31 GMT\r\n"
-> "X-Powered-By: ASP.NET\r\n"
-> "\r\n"
-> "HTTP/1.1 200 OK\r\n"
-> "Server: Microsoft-IIS/5.0\r\n"
-> "Date: Sun, 18 Nov 2007 17:52:31 GMT\r\n"
-> "X-Powered-By: ASP.NET\r\n"
-> "Connection: close\r\n"
-> "Content-Type: text/html\r\n"
-> "Content-Length: 151\r\n"
-> "\r\n"
reading 151 bytes...
-> ""
-> "<HTML><BODY><H3>The following errors have occurred."
-> "</H3>(13) The merchant login ID or password is invalid or the account is 
inactive.<BR></BODY></HTML>"
read 151 bytes
Conn close
Response Code = 200
Response Content Length = 151
Response Body = "<HTML><BODY><H3>The following errors have occurred.</H3>(13) 
The merchant login ID or password is invalid or the account is 
inactive.<BR></BODY></HTML>"




-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

Reply via email to