The remote certificate is invalid according to the validation procedure

Aug 11, 2008 at 10:03 AM

I got the above error message when I load my ASP.NET application.

below is my source code at Page Load event

  protected void Page_Load(object sender, EventArgs e)
        // ApplicationKey and Secret are acquired when you sign up for
        _fbService.ApplicationKey = FACEBOOK_API_KEY;
        _fbService.Secret = FACEBOOK_SECRET;

       // _fbService.IsDesktopApplication = false;

        string sessionKey = Session["facebook_session_key"] as String;
        string userId = Session["facebook_userId"] as String;

        // When the user uses the facebook login page, the redirect back here will will have the auth_token in the query params
        string authToken = Request.QueryString["auth_token"];

        if (!String.IsNullOrEmpty(sessionKey))
            // We have already established a session on behalf of this user
            _fbService.SessionKey = sessionKey;
            _fbService.uid = Convert.ToInt64(userId);
        else if (!String.IsNullOrEmpty(authToken))
            // This will be executed when facebook login redirects to our page
            Session["facebook_session_key"] = _fbService.SessionKey;
            Session["facebook_userId"] = _fbService.uid;
            Session["facebook_session_expires"] = _fbService.SessionExpires;
        else // Need to login
            Response.Redirect(@"" + FACEBOOK_API_KEY + @"&v=1.0");

        if (!IsPostBack)
            MyFriendList.Friends = _fbService.friends.GetFriends();

The exception was thrown by

Aug 11, 2008 at 3:36 PM
I also get the same error with the latest build v2.0 RC0.
Aug 12, 2008 at 5:08 AM
Do you get certificate problems if you try to hit the new api url from a browser?
Aug 13, 2008 at 6:51 PM
I am having the same issue; does anyone have a solution to "The remote certificate is invalid according to the validation procedure."?
Aug 18, 2008 at 12:17 AM
I'm also having the same issue - trying a basic sample like vccsee.  Any help on this would be appreciated.

Aug 18, 2008 at 3:26 AM
rpowers119:  Do you mean this URL?

Or something else?

Aug 18, 2008 at 3:41 AM
Oh, maybe this one?

Either way - both URLs give me back xml, not an error.
Aug 18, 2008 at 8:27 AM
Anyone can help to solve ?
Aug 19, 2008 at 1:06 AM
I'm getting the same error: "The remote certificate is invalid according to the validation procedure." {System.Security.Authentication.AuthenticationException}

Aug 19, 2008 at 5:00 AM
Check out this other thread.

I never see the certificate problem.  But, Elmar posted a solution...  Let me know if that fixes your issues.
Aug 20, 2008 at 4:20 AM

Well, it changed my error message:

Exception Details: System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=, Culture=neutral, PublicKeyToken=xxxxxxxxxxxxxxxx' failed.

Did this work for anyone else?

Aug 20, 2008 at 4:54 AM
elmar's suggestion did work for me..
Aug 21, 2008 at 7:01 AM
Please try to use the API directly. You can encapsulate the calls to it like so:

        private facebook.API GetAPI()
            var api = new facebook.API();
            api.ApplicationKey = <APPID>;
            api.Secret = <APPSECRET>;
            api.SessionKey = HttpContext.Current.Session["fb_session_key"] as string;
            api.IsDesktopApplication = false;   // <- Don´t forget. This moved to the API bits now and probably causes most errors some of you run into
            return api;
Aug 21, 2008 at 1:48 PM
Edited Aug 21, 2008 at 1:56 PM
I had the same problem today, I just added:

_fbService.API.IsDesktopApplication = false;

to the code from the User's Guide.

Edit: I probably don't know what I'm talking about... I'm still getting an error.
Aug 25, 2008 at 5:09 PM
I'm getting the error also, my code is very similar to the original post.  Has anyone found a solution for this yet?  Is the code in the original post the correct approach to get a list of friends from a web app?
Aug 27, 2008 at 9:40 AM
I found a solution that works for me:

I added the following code before calling CreateSession:

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

ServicePointManager.ServerCertificateValidationCallback = delegate(Object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
    return true;
Aug 27, 2008 at 3:57 PM
I've made updates to the api code that should fix this.  Please get the latest source code drop.
Aug 27, 2008 at 5:58 PM
Getting this error now, but this is first time I've gotten a build like this...

Incorrect signature

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: facebook.Utility.FacebookException: Incorrect signature

Source Error:

Line 36:         If (Not IsPostBack) Then
Line 37: ' Use the FacebookService Component to populate Friends
Line 38: For Each _friend As user In _fbService.friends.getUserObjects()
Line 39: chkFriends.Items.Add(New ListItem(_friend.first_name & " " & _friend.last_name, _friend.uid))
Line 40: Next

Source File: C:\Users\Adam\Documents\Visual Studio 2008\Projects\bnAlerts\BNAlerts\FaceBookText20\Default.aspx.vb    Line: 38

Stack Trace:

[FacebookException: Incorrect signature]
facebook.API.SendRequest(IDictionary`2 parameterDictionary, Boolean useSession) in C:\Users\Adam\Documents\Visual Studio 2008\Projects\Facebook2RC2\Source\Facebook\API.cs:550
facebook.API.SendRequest(IDictionary`2 parameterDictionary) in C:\Users\Adam\Documents\Visual Studio 2008\Projects\Facebook2RC2\Source\Facebook\API.cs:515
facebook.friends.getUserObjects(Int64 flid) in C:\Users\Adam\Documents\Visual Studio 2008\Projects\Facebook2RC2\Source\Facebook\friends.cs:165
facebook.friends.getUserObjects() in C:\Users\Adam\Documents\Visual Studio 2008\Projects\Facebook2RC2\Source\Facebook\friends.cs:148
_Default.Page_Load(Object sender, EventArgs e) in C:\Users\Adam\Documents\Visual Studio 2008\Projects\bnAlerts\BNAlerts\FaceBookText20\Default.aspx.vb:38
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +50
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627

Aug 27, 2008 at 7:54 PM
Does this same behavior happen if you refer to the dll's and when you refer to the assemblies?
Aug 27, 2008 at 8:04 PM
I get the error either way.  For some reason though, I have to build in debug mode, I get build errors when trying to build the Facebook source code in release mode:

Error    4    The type 'Microsoft.Xml.Schema.Linq.IXMetaData' is defined in an assembly that is not referenced. You must add a reference to assembly 'Microsoft.Xml.Schema.Linq, Version=0.10.1000.0, Culture=neutral, PublicKeyToken=null'.    C:\Users\Adam\Documents\Visual Studio 2008\Projects\Facebook2RC2\Source\Facebook.web\PhotoAlbum.cs    33    30    facebook.web

Sep 4, 2008 at 9:32 PM

I changed this line to: _fbService.IsDesktopApplication = false to: _fbService.API.IsDesktopApplication = false; And that error went away.
Oct 17, 2008 at 4:26 PM
Long time since the last post, so I don't know if this issue is solved for everybody.

What I did and it worked:

  1. Add ServicePointManager.ServerCertificateValidationCallback = delegate(Object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors){return true;};
  2. Add this fbService.API.IsDesktopApplication = false; after creating the instance of FacebookService