views:

9

answers:

0

I am trying to setup Postfix with SMTP and with TLS on to be used by rails 2.3.10 app.

email.yml settings are as follows: my mail server is domain1.com

production:
  :enable_starttls_auto: true
  :address: domain1.com
  :domain: domain1.com
  :port: 25
  :authentication: :login
  :user_name: username
  :password: passwd

Postfix is configured to use SASL for SMTP AUTH

I believe this setup is good 'cos when I do the following

openssl s_client -connect domain1.com:25 -starttls smtp

I get a successful response with the username and password that I used in the email settings above. and the self-signed certificates look ok with my domain1.com in them

CONNECTED(00000003)
depth=0 /C=US/ST=/O=domain1.com/CN=domain1.com
verify error:num=18:self signed certificate
verify return:1
depth=0 /C=US/ST=/O=domain1.com/CN=domain1.com
verify return:1
---
Certificate chain
 0 s:/C=US/ST=/O=domain1.com/CN=domain1.com
   i:/C=US/ST=/O=domain1.com/CN=domain1.com
---

Server certificate
-----BEGIN CERTIFICATE-----
MIIC5DCCAk2gAwIBAgIJAJ3SpxFwbZSbMA0GCSqGSIb3DQEBBQUAMFYxCzAJBgNV
BAYTAlVTMQswCQYDVQQIEwJPUjEcMBoGA1UEChMTY2FuaWFmZm9yZGl0bm93LmNv
41GeDtKRmfi5cYi1Go3xULSjcklsr2dNAozI/qfDzRYTxzK/NSJHuDCJ9qzFoz/i
wAsUC352ITTerU3qLRmSqEK4i2fL2cNoGUd1CA1fhQmE4ynL5GwydR2ULrv5A3cG
xc7T64uSm4SawlOADhKY6kuSZ5MvGKZe
-----END CERTIFICATE-----
subject=/C=US/ST=/O=domain1.com/CN=domain1.com
issuer=/C=US/ST=/O=domain1.com/CN=domain1.com
---
No client certificate CA names sent
---
SSL handshake has read 1535 bytes and written 354 bytes
---
New, TLSv1/SSLv3, Cipher is xxx-RSA-xxx-SHA
Server public key is 1024 bit
Secure Renegotiation IS supported
Compression: NONE
Expansion: NONE
SSL-Session:
    Protocol  : TLSv1
    Cipher    : xxx-RSA-xxx-SHA
    Session-ID: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    Session-ID-ctx: 
    Master-Key: xxxxxxxxxxxxx
    Key-Arg   : None
    Start Time: 1287567113
    Timeout   : 300 (sec)
    Verify return code: 18 (self signed certificate)
---
250 DSN
auth plain xxxxxx
235 2.7.0 Authentication successful

Now the error: When I send a mail from my rails app, I get the dreaded error message

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

I have googled to no avail.

As an experiment, I have tried turning off tls by setting :enable_starttls_auto: false but no change in the result.

Postfix /etc/postfix/main.cf settings related to sasl and tls

smtpd_use_tls= yes
smtpd_sasl_local_domain = $myhostname
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous

broken_sasl_auth_clients = yes
smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,reje$

smtpd_tls_auth_only = yes
smtp_tls_note_starttls_offer = yes
smtp_sasl_auth_enable = yes
smtp_use_tls = yes

Any clues will be greatly appreciated.

Thank you.