The remote certificate is invalid according to the validation procedure.

Posted by Shanky11 under ASP.NET on 10/23/2012 | Points: 10 | Views : 101436 | Status : [Member] | Replies : 17
The remote certificate is invalid according to the validation procedure.
what kind of error is this????????????????/




Responses

Posted by: Seng2hs on: 10/23/2012 [Member] Starter | Points: 25

Up
0
Down
Are you trying to send mail using SmtpClient???
if yes,

1. Make sure you have ssl enabled
var client = new SmtpClient();
client.EnableSsl = true;




Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Shanky11 on: 10/23/2012 [Member] Starter | Points: 25

Up
0
Down
i have done this but yet this error ?????????? when i run on iis it works but when i triedf this on my live website it shows renote certifcate is invalid acccording to validation procedure

Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Seng2hs on: 10/23/2012 [Member] Starter | Points: 25

Up
0
Down
enter the below code somewere before smtpclient.Send():

ServicePointManager.ServerCertificateValidationCallback = delegate(object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { return true; };

Try this.



Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Shanky11 on: 10/23/2012 [Member] Starter | Points: 25

Up
0
Down
i hav tried this
actuallly its runing all rt on iis but its not running on my website page on live proj

Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Seng2hs on: 10/23/2012 [Member] Starter | Points: 25

Up
0
Down
Check with your website hosting provider.

May be they might have blocked the port for sending the mail.



Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Shanky11 on: 10/23/2012 [Member] Starter | Points: 25

Up
0
Down
mail is receving and sending from that mail id from whch i m sending mail

Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Seng2hs on: 10/23/2012 [Member] Starter | Points: 25

Up
0
Down
Have you hosted your application in shared hosting???
if no, Can you able to login into your server?? if Yes, check the antivirus port execption.
I am sure that, anti virus is blocking the port.

The same problem i have face before, then i added the port in the antivirus port execption.






Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Shanky11 on: 10/23/2012 [Member] Starter | Points: 25

Up
0
Down
1..i m able to login to myserver tell me where i hav to allow port in antivirus ??????????

2..<add key="HostPath" value="smtp.gmail.com"/>
<add key="UserName" value="h.c@infrainvest.in"/>
<add key="Password" value="5874"/>
<add key="MailFrom" value="h.c@infrainvest.in"/>
see above web.config file
tell me is htis correct


Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Shanky11 on: 10/23/2012 [Member] Starter | Points: 25

Up
0
Down
go to infrainvest.in website >Home Page Left side Clik On Subscribe
Button

Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ranjeet_8 on: 10/23/2012 [Member] [MVP] Gold | Points: 25

Up
0
Down
@ Shanky11
If you are behind proxy Server.
You need to add your proxy ip address in your web.config file
Example:-

<SYSTEM.NET>
<DEFAULTPROXY>
<PROXY proxyaddress="YourProxyIpAddress" />
</DEFAULTPROXY>
</SYSTEM.NET>

C# Code

SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com";
smtp.Port = 587;
smtp.UseDefaultCredentials = False;
smtp.Credentials = new System.Net.NetworkCredential
("YourUserName@gmail.com","YourGmailPassword");
smtp.EnableSsl = true;
smtp.Send(mail);


Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Seng2hs on: 10/23/2012 [Member] Starter | Points: 25

Up
0
Down
Are you able to login into gmail account using h.c@infrainvest.in username???
first you should use gmail username and password for authntication.

also pls try this below code

MailMessage objmensaje = new MailMessage();
objmensaje.From = new MailAddress("from@gmail.com");
objmensaje.To.Add("to@hotmail.com");

objmensaje.Subject="Prueba";

objmensaje.Body="message";

SmtpClient objservidor = new SmtpClient("smtp.gmail.com");
objservidor.Port="587";
objservidor.Credentials = new System.Net.NetworkCredential("your@gmail.com","passord");
objservidor.EnableSssl=True;

try
{
objservidor.Send(objmensaje);
Response.Write("Done");
}
catch(SmtpException ex)
{
Respose.Write(ex.Message);
}


Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Shanky11 on: 10/23/2012 [Member] Starter | Points: 25

Up
0
Down
yes i m able to login with that and ur code is same as my

Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Shanky11 on: 10/23/2012 [Member] Starter | Points: 25

Up
0
Down
no its main server

Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Seng2hs on: 10/23/2012 [Member] Starter | Points: 25

Up
0
Down
What anti virus is installed in your server???

Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Shanky11 on: 10/23/2012 [Member] Starter | Points: 25

Up
0
Down
no antivrus in installed on server

Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Seng2hs on: 10/23/2012 [Member] Starter | Points: 25

Up
0
Down
If Windows Firewall is blocking a program and you want to allow that program to communicate through the firewall, you can usually do that by selecting the program on the Exceptions tab in Windows Firewall

However, if the program isn't listed on the Exceptions tab, you might need to open (add) a port

1.Open Windows Firewall by clicking the Start button , clicking Control Panel, clicking Security, and then clicking Windows Firewall.

2.Click Allow a program through Windows Firewall. If you are prompted for an administrator password or confirmation, type the password or provide confirmation.

3.Click Add port.

4.In the Name box, type a name that will help you remember what the port is used for.

5.In the Port number box, type the port number.

6.Click TCP or UDP, depending on the protocol.

7.To change scope for the port, click Change scope, and then click the option that you want to use. ("Scope" refers to the set of computers that can use this port opening.)


Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Shanky11 on: 10/23/2012 [Member] Starter | Points: 25

Up
0
Down
the remote certificate is invalid according to the validation procedure. Tell me about this error

Shanky11, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response