OpenSSL::SSL::SSLError (hostname was not match with the server certificate)

I got this error in one of my Rails apps that I migrated to 2.2. It occurs when you try and send mail with ActionMailer, which makes it especially annoying because the exception notifications I normally receive when there is a problem weren’t being sent!

I wasn’t able to track down the root cause of the problem – apparently something about an SSL certificate not being there or not being right, but here’s the change that causes ActionMailer to fool around with SSL mail:

http://github.com/rails/rails/commit/732c724df61bc8b780dc42817625b25a321908e4

I was able to “correct” the problem (or at least get things working again) by commenting out this line of code:

smtp.enable_starttls_auto if smtp.respond_to?(:enable_starttls_auto)

Perhaps it should be a configuration option, or there should be better error detection with regards to the certificate. If anyone comes up with a nicer answer, leave a comment, but in the meantime, I thought I’d post my quick and dirty fix.

Update

I fixed the problem by running this as root:

make-ssl-cert generate-default-snakeoil --force-overwrite

Which regenerates the SSL certificates.

Leave a comment