开发者

Cannot send HttpWebRequest with certificate from SharePoint

开发者 https://www.devze.com 2023-03-04 15:17 出处:网络
I\'m trying to send a HttpRequest from my SharePoint 2007 WebPart to another web service. The service expects a X509 client certificate for authentication.

I'm trying to send a HttpRequest from my SharePoint 2007 WebPart to another web service. The service expects a X509 client certificate for authentication.

I wrote a simple console application that has no problem in sending the request and authenticating with my certificate:

byte[] certBytes = getBytes();
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("<server_url>");
X509Certificate2 cert = new X509Certificate2(certBytes, "<password>", X509KeyStorageFlags.MachineKeySet);
request.ClientCertificates.Add(cert);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();

But as soon as run the same code from my SharePoint Webpart it fails because it "Cannot create secure SSL/TSL connection".

Remark: If I don't use the X509KeyStorageFlags.MachineKeyS开发者_运维百科et flag, I get "Access denied" on SharePoint. According to http://social.msdn.microsoft.com/Forums/en/windowssecurity/thread/f1981374-5a25-45c7-aea8-aad859800ae7 the flag should fix this.

The (Apache based) web service logs the following error:

[error] Re-negotiation handshake failed: Not accepted by client!?

Any idea why the same code works for my console app, but not on SharePoint?

0

精彩评论

暂无评论...
验证码 换一张
取 消