locked
Skip SMTP SSL certificate validation RRS feed

  • Question

  • Hello all,

    I am currently experiencing an issue with sending an email over authenticated & SSL secured SMTP.

    I successfully tested the following code with a well known third party e-mail provider using also authenticated & SSL secured SMTP.
    However, it is not working with my own SMTP server which also uses authenticated & SSL secured SMTP but with a self-signed certificate.

    The exact error message that is thrown is "The transport failed to connect to the server." which most probably is due to the certificate not being successfully validated.

    I tried importing the certificate into Windows, but this didn't solve my problem.

    Has anyone of you experienced the same problem or know how one can skip the certificate validation?

    Below you can find my code which I mentioned above.

     

    public void send(){
     string user = "myusername"; string pswd = "mypassword"; string server = "mail.company.com"; CDO.Message message = new CDO.Message(); CDO.IConfiguration configuration = message.Configuration; ADODB.Fields fields = configuration.Fields; ADODB.Field field = fields["http://schemas.microsoft.com/cdo/configuration/smtpserver"]; field.Value = server; field = fields["http://schemas.microsoft.com/cdo/configuration/smtpserverport"]; field.Value = 465; field = fields["http://schemas.microsoft.com/cdo/configuration/sendusing"]; field.Value = 2; field = fields["http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"]; field.Value = CDO.CdoProtocolsAuthentication.cdoBasic; field = fields["http://schemas.microsoft.com/cdo/configuration/sendusername"]; field.Value = user; field = fields["http://schemas.microsoft.com/cdo/configuration/sendpassword"]; field.Value = pswd; field = fields["http://schemas.microsoft.com/cdo/configuration/smtpusessl"]; field.Value = "true"; field = fields["http://schemas.microsoft.com/cdo/configuration/sendemailaddress"]; field.Value = getSender(); fields.Update(); message.From = getSender(); message.To = getRecipient(); message.Subject = getSubject(); message.TextBody = getMessage(); message.Send();
    }

     

    Thanks in advance for any help you could provide on this.


    • Edited by LaurensR Tuesday, November 29, 2011 7:44 PM html line breaks inserted in my code
    Tuesday, November 29, 2011 7:43 PM

All replies

  • Dear Elair, have you found a solution for this? I'm experiencing the same problem.

    Thank you in advance.


    Friday, October 5, 2012 2:32 PM
  • Can you give more details on your exact problem?  There are few methods iused to log on to a SSL website and the method you use will depend on the firewall install on your network.   A firewall will use port forwarding so you may have to setup a min-server to allow you to change your port number.

    jdweng

    Friday, October 5, 2012 4:44 PM
  • Actually, I got the same problem. I know the reason, but i dont know to workaround it.

    The reason is that your certificate (on your SMTP server was found incorrect by System.Web.Mail) in my case it is Incorrect Principal Name error on certification validation.

    I have tried to trap event

    ServicePointManager.ServerCertificateValidationCallback = ServerCertificateValidationCallback;

    but it doesnt raise this event.

    I tried to use System.Net.Mail but it doesnt support implisit SSL.

    If any MS guru guys can help, would be apriciate.

    Wednesday, December 26, 2012 9:45 AM
  • See code project below.  I often like the author of the article use wireshark to help isolate issues with my code.  Another suggestion is to put the URL into a IE and see if that works.  sometimes the IE will indicate that you need to download a certficate and will provide instructions.  If downloading a certificate is a one time opteration yoiu may not want to include it as part of your application.  Instead let the users manually download the certificate.

    http://www.codeproject.com/Articles/326574/An-Introduction-to-Mutual-SSL-Authentication


    jdweng

    Wednesday, December 26, 2012 11:22 AM