Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
When I am using following code, which takes location name & returns latitude & longitude; Subgurim.Controles.GMap.geoCodeRequest(......) it is showing an error:

System.Security.Authentication.AuthenticationException: The remote certificate is invalid according to the validation procedure.

The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel


How do I fix it?
Posted
Updated 18-Feb-17 19:38pm
v4
Comments
Dalek Dave 10-Jun-11 3:52am    
Edited for Grammar, Syntax and Readability.

C#
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;

//add following code before smtpClient.Send()

smtpClient.EnableSsl = true;

ServicePointManager.ServerCertificateValidationCallback = delegate(object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { return true; };
 
Share this answer
 
Comments
jayashree shinde 28-Dec-12 4:23am    
yes solution 4 is rt ...Thnx
Showne 23-Feb-13 1:30am    
I think, SMTP for Gmail configuration it is not needed but for using local mail server it is very very important. Thanx a lot..
Member 14831145 13-May-20 15:55pm    
You guys know what exactly happen when you use the above block of code, I think no. Using this you are exposing your data over TCP/Network and may allow your encrypted message to be read by an attacker. Thanks #Joshi MGR
 
Share this answer
 
Comments
Dalek Dave 10-Jun-11 3:53am    
Nice Spot.
Couldn't find enough information to get to the root of problem.

But check http://gathadams.com/category/google-maps/[^], and try to make a simple application to check if it works.
 
Share this answer
 
In my case I solved the problem by calling the web service by name instead of IP.

I just modified the host file (c:\Windows\System32\Drivers\etc\hosts)

for example I added new line to host file like (50.50.50.50 myservice-name.com.jo)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900