467,102 Members | 1,130 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,102 developers. It's quick & easy.

"The remote certificate is invalid according to the validation procedure"


Hello,

I'm trying to connect to a system via https. As an additional security
measure, the server requires me to attach an x509 certs to my "HTTP POST"
request.


I get the error described in the subject.

see code listing below:

bool result = false; ;

X509Certificate2 Certificate = null;

X509Store store = new X509Store(StoreName.My, StoreLocation.CurrentUser);
store.Open(OpenFlags.ReadOnly | OpenFlags.OpenExistingOnly);

try

{

X509Certificate2Collection collection =
(X509Certificate2Collection)store.Certificates;

X509Certificate2Collection fcollection =
(X509Certificate2Collection)collection.Find(X509Fi ndType.FindBySubjectName,
ConfigurationManager.AppSettings["SN"], false);

if (fcollection.Count == 0)

throw new Exception("Unable to find certificate!");

else

{

Certificate = fcollection[0];

// Certificate.

HttpWebRequest req =
(HttpWebRequest)HttpWebRequest.Create(Configuratio nManager.AppSettings["URI"]);

req.ClientCertificates.Add(Certificate);

req.Connection.

// if (ConfigurationManager.AppSettings["IRW_URI"].ToString()!="") req.Proxy
= new System.Net.WebProxy(ConfigurationManager.AppSettin gs["ProxyString"],
true);

req.ContentType = "application/x-www-form-urlencoded";

// req.Method = "POST";

// req.AuthenticationLevel = System.Net.Security.AuthenticationLevel.None;
byte[] bytes =
System.Text.Encoding.ASCII.GetBytes(Utility.Conver tMessagetoUTF8("data"));

req.ContentLength = bytes.Length;

System.Net.WebResponse resp = req.GetResponse();

......

......

.....

.....

......

The remote certificate is invalid according to the validation procedure

well googling haviong resolved the issue yet.

can someone help?

Thanks

JJ


Apr 19 '06 #1
  • viewed: 5184
Share:

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Hans-Dieter Franz | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.