Answered by:
Error Getting Access Token on SharePoint 2010 development

Question
-
Hi to all,
I implemented the sample proposed in the link :
http://msdn.microsoft.com/en-us/library/hh454950.aspx
This works flawless on a console application, when i tryed to implement on SharePoint 2010 (specifically in an IHttpHandler '.ashx'file) i getting the error bellow on webRequest.GetRequestStream()
Error :
The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.
at System.Net.HttpWebRequest.GetRequestStream(TransportContext& context)
at System.Net.HttpWebRequest.GetRequestStream()Can anyone help me ?
Regards!
SharePoint Solution Architect
Friday, August 9, 2013 10:52 PM
Answers
-
This looks like a certificate issue. Could you check if you Sharepoint code is overwriting this setting here
System.Net.ServicePointManager.ServerCertificateValidationCallback = RemoteCertificateValidationCallback;
and possibly refusing the certificate? If the callback returns false it will refuse the certificate:
private static bool RemoteCertificateValidationCallback(Object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors){ /*some validation code*/ return false; } <-- this would fail the call.
- Marked as answer by Vikram Dendi Tuesday, August 13, 2013 9:32 PM
Tuesday, August 13, 2013 9:27 PM
All replies
-
Nobody ?
SharePoint Solution Architect
Monday, August 12, 2013 5:00 PM -
Sergio - I've passed this on to our API developers. Stay tuned.
Vikram Dendi, Director of Product Management
Microsoft TranslatorTuesday, August 13, 2013 8:30 PM -
This looks like a certificate issue. Could you check if you Sharepoint code is overwriting this setting here
System.Net.ServicePointManager.ServerCertificateValidationCallback = RemoteCertificateValidationCallback;
and possibly refusing the certificate? If the callback returns false it will refuse the certificate:
private static bool RemoteCertificateValidationCallback(Object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors){ /*some validation code*/ return false; } <-- this would fail the call.
- Marked as answer by Vikram Dendi Tuesday, August 13, 2013 9:32 PM
Tuesday, August 13, 2013 9:27 PM -
Eric,
You are the Guy ! this works.
Now i will explain what i do to solve my issue.
Like i explained above, i using a HttpHandler (.ashx file) an on the ProcessRequest I defined this :
public void ProcessRequest(HttpContext context)
{
if (context == null || context.Request == null)
return;
System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate(object sender1, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
{
bool validationResult = true;
return validationResult;
};
And works.
Thanks a lot Eric and Vikram
Regards !
SharePoint Solution Architect
Wednesday, August 14, 2013 2:00 AM