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

Aug 11, 2008 at 10:04 PM
Hi all,

I am getting the following error when creating the session using fbservice object.

Here is my code:

Partial Class test_Default
    Inherits System.Web.UI.Page
    Private fbService As facebook.Components.FacebookService = New facebook.Components.FacebookService()
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        ' ApplicationKey and Secret are acquired when you sign up for
        fbService.ApplicationKey = "xxxxxxxxxxxxxxx"
        fbService.Secret = "xxxxxxxxxxxxxxx" 

        Dim sessionKey As String = TryCast(Session("facebook_session_key"), String)
        Dim userId As String = TryCast(Session("facebook_userId"), String)

        ' When the user uses the facebook login page, the redirect back here will will have the auth_token in the query params
        Dim authToken As String = Request.QueryString("auth_token")

        If Not [String].IsNullOrEmpty(sessionKey) Then
            ' We have already established a session on behalf of this user
            fbService.SessionKey = sessionKey
            fbService.uid = userId
        ElseIf Not [String].IsNullOrEmpty(authToken) Then
            ' This will be executed when facebook login redirects to our page
            fbService.CreateSession(authToken)
            Session("facebook_session_key") = fbService.SessionKey
            Session("facebook_userId") = fbService.uid
            Session("facebook_session_expires") = fbService.SessionExpires
        Else
            ' Need to login
            Response.Redirect("http://www.facebook.com/login.php?api_key=" + fbService.ApplicationKey + "&v=1.0")
        End If

        If Not IsPostBack Then
            RefreshFBML()
        End If
    End Sub
    Private Sub RefreshFBML()   
        Response.Write("Testing the apps dude.....")
        fbService.profile.setFBML(fbService.uid, "I am testing the apps...", "I am testing the apps...", "")
    End Sub
End Class

Can anyone please help me in getting resolved this problem.


Aug 11, 2008 at 10:33 PM
Edited Aug 12, 2008 at 8:02 AM
Hi,
I'm using VB 2008 Express Edition with the latest Facebook RC2 DLLs in a fresh application, on Windows Vista.

I created a new desktop application on Developer Facebook so I have the key and secret.

All the app does is try to connect to Facebook (a test app).

I get the same error as above:
The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel

When running:
tiggTagService.ConnectToFacebook()

The app key and secret were set in the tiggTagService (FacebookService) properties.

The login screen loads, but the error happens when I click Sign-In.
The inner exception is "The remote certificate is invalid according to the validation procedure".

I saw there are more topics on this board about that error so I'll have a look as well...

Can anyone advise on this?
Aug 12, 2008 at 8:36 AM
BTW,
I found that using:

tiggTagService.GetExtendedPermission(facebook.Types.Enums.Extended_Permissions.offline_access)
           
It loads a login screen that allows me to log on to my facebook profile just fine.

So what is the difference between this line and tiggTagService.ConnectToFacebook() ?

tiggTagService.ConnectToFacebook() try to log-in as an application. 
Does it use different security settings?

A different URL?
Aug 12, 2008 at 9:05 AM
I also found that:
        public void ConnectToFacebook()
        {
            if (IsDesktopApplication)
            {
                DialogResult result;
                api.SetAuthenticationToken();

                using (var formLogin = new FacebookAuthentication(LoginUrl))
                {
                    result = formLogin.ShowDialog();
                }
                if (result == DialogResult.OK)
                {
                    api.CreateSession();
                }
                else
                {
                    throw new Exception("Login attempt failed");
                }
            }
        }

api.CreateSession(); can also receive an authentication key.

I read on the Login Desktop App resource that I need to have a PHP file run on my server to give new authentication keys to any session that is trying to be created.

Does anyone have a working example for this?
Has anyone managed to "get a list of friends" from Facebook using the new RC 2.0 for DESKTOP?

Please share your ideas, comments and code :)
Sep 25, 2008 at 5:03 AM
Hi All,
Is there any other way to resolve the error 
The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.

Its very urgent. Can any one please help me if they found the reason for the error.

Thanks & Regards,
Phani...
Sep 25, 2008 at 7:50 AM
I think I already answered this one. Please use the search.
Either modify the source like stated in my explanation or -if you are creating a wep app- use the API and set it to isDesktopApp = false.

Elmar
Sep 25, 2008 at 7:50 AM
I think I already answered this one. Please use the search.
Either modify the source like stated in my explanation or -if you are creating a wep app- use the API and set it to isDesktopApp = false.

Elmar
May 4, 2009 at 12:51 PM
Edited May 4, 2009 at 12:57 PM
Hi guys,
I have encountered this problem myself while using the Binaries Facebook .Net toolkit and after some drilling i found that a specific version of Facebook.dll assembly is Mal-functioning.
you can see the difference at this page.... , it demonstrate the difference between the two Facebook.dll assemblies and specify which one is working and which one does not.
Make a long story short :) do not use the  2.0.3142.23334 version of Facebook.dll assembly.

Kind Regards
Yaniv arazi