Wednesday, December 14, 2011

Using actionwebservice with Rails 2.3/3.1

I added the datanoise-actionwebservice gem to my Rails 2.3 project that I upgraded from Rails 1.2.6. I also had another project that I had upgraded to Rails 3.1 that happened to use the httpclient 2.2.4 gem. When trying to connect to a SOAP service endpoint over HTTPS using soap4r and an IP address instead of the server name, I got a SSL error with this partial stack trace:

OpenSSL::SSL::SSLError (hostname was not match with the server certificate):
/usr/lib/ruby/1.8/openssl/ssl-internal.rb:123:in `post_connection_check'
httpclient (2.2.4) lib/httpclient/session.rb:313:in `post_connection_check'
httpclient (2.2.4) lib/httpclient/session.rb:740:in `connect'
httpclient (2.2.4) lib/httpclient/timeout.rb:131:in `timeout'
httpclient (2.2.4) lib/httpclient/session.rb:731:in `connect'
httpclient (2.2.4) lib/httpclient/session.rb:594:in `query'
httpclient (2.2.4) lib/httpclient/session.rb:161:in `query'
httpclient (2.2.4) lib/httpclient.rb:1060:in `do_get_block'
httpclient (2.2.4) lib/httpclient.rb:869:in `do_request'
httpclient (2.2.4) lib/httpclient.rb:956:in `protect_keep_alive_disconnected'
httpclient (2.2.4) lib/httpclient.rb:868:in `do_request'
httpclient (2.2.4) lib/httpclient.rb:756:in `request'
httpclient (2.2.4) lib/httpclient.rb:666:in `post'
/usr/lib/ruby/1.8/soap/streamHandler.rb:170:in `send_post'
/usr/lib/ruby/1.8/soap/streamHandler.rb:109:in `send'
/usr/lib/ruby/1.8/soap/rpc/proxy.rb:170:in `route'
/usr/lib/ruby/1.8/soap/rpc/proxy.rb:141:in `call'
/usr/lib/ruby/1.8/soap/rpc/driver.rb:178:in `call'
/usr/lib/ruby/1.8/soap/rpc/driver.rb:232:in `get_account_id'
/usr/lib/ruby/gems/1.8/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/client/soap_client.rb:63:in `send'
/usr/lib/ruby/gems/1.8/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/client/soap_client.rb:63:in `perform_invocation'
/usr/lib/ruby/gems/1.8/gems/datanoise-actionwebservice-2.3.2/lib/action_web_service/client/base.rb:15:in `method_missing'

Thanks to jkraemer's post, I was able to add a file under lib/soap/property in my Rails app containing the setting:
client.protocol.http.ssl_config.verify_mode=OpenSSL::SSL::VERIFY_NONE
and the error went away. There are probably ways to configure this to use a specific cert as well, but I didn't investigate those.

Sunday, December 11, 2011

jQuery autocomplete source issues

I was trying to get a jQuery version 1.8 autocomplete call to work in Rails 3.1 without using the fancy helpers.  I had something like:

$(function() {
  $('#project-list-autocomplete').autocomplete({
    source: "/rails_controller/json_action"
  });
where json_action is a method that returns the autocomplete values, but I couldn't figure out the format of the JSON. It's:
[{"id":"1", "label":"autoanswer1"}, 
{"id":"2", "label":"autoanswer2"}]

and so on.

Monday, October 10, 2011

SSL negotiation failed: SSL error code -1/1/336032856

I got this error when attempting to connect a Subversion client to a Subversion server I had just configured to run over Apache.  The cause is that the certificate validation fails because the ServerName in the SSL virtual host entry doesn't match the server you're connecting to.

If you're trying to connect to https://svn.mycompany.com, make sure your ServerName entry reads:
ServerName svn.mycompany.com:443
and the problem should go away.

Friday, October 7, 2011

systemd Service won't start? Try --skip-redirect

On Fedora 15, I was trying to start the yum-installed nginx.  I was aware of potential port issues, so I put it on a unique port.  Something was still wrong with my configuration, but I couldn't tell what, because
service nginx start
wasn't reporting any useful information, and neither were /var/log/messages or the nginx logs.
Thanks to http://forums.fedoraforum.org/showthread.php?t=270346, I was able to run
service nginx restart --skip-redirect
The --skip-redirect flag tells it to not redirect output to systemctl, so you can actually see the error messages from whatever configuration issue you had and fix them.