Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Mobile Development
  3. Mobile
  4. Can not connect to SSL web service from windows mobile.

Can not connect to SSL web service from windows mobile.

Scheduled Pinned Locked Moved Mobile
helpsysadminsecurity
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Chetan Ranpariya
    wrote on last edited by
    #1

    Hi Friends, I am developing a Windows Mobile application using 6.0 professional SDK. Here I am consuming a web service which is hosted on HTTPS. I am able to add the web reference successfully but when I call a method of the service using proxy it throws following exception. "Could not establish trust relationship with remote server." The same scenario works fine if I test it with a desktop windows application. I am able to call the method successfully and I receive the response too, but I dont know why it is not working with Windows Mobile. I am able to browse the websites from the mobile browser so there is no issue about the connection. Please help me soon friends I m running out of time...I have search all over the world during last 2 days but could not find any satisfactory and working solution. Thank you all in advance.

    Thanks and Regards, Chetan Ranpariya

    J C 2 Replies Last reply
    0
    • C Chetan Ranpariya

      Hi Friends, I am developing a Windows Mobile application using 6.0 professional SDK. Here I am consuming a web service which is hosted on HTTPS. I am able to add the web reference successfully but when I call a method of the service using proxy it throws following exception. "Could not establish trust relationship with remote server." The same scenario works fine if I test it with a desktop windows application. I am able to call the method successfully and I receive the response too, but I dont know why it is not working with Windows Mobile. I am able to browse the websites from the mobile browser so there is no issue about the connection. Please help me soon friends I m running out of time...I have search all over the world during last 2 days but could not find any satisfactory and working solution. Thank you all in advance.

      Thanks and Regards, Chetan Ranpariya

      J Offline
      J Offline
      Joel Ivory Johnson
      wrote on last edited by
      #2

      The first thing I would check is the date and time on your Windows Phone. It it is wrong then SSL authentication will fail.


      Joel Ivory Johnson

      J2i.net | @J2iNet | Mobile Device Development MVP

      C J 2 Replies Last reply
      0
      • J Joel Ivory Johnson

        The first thing I would check is the date and time on your Windows Phone. It it is wrong then SSL authentication will fail.


        Joel Ivory Johnson

        J2i.net | @J2iNet | Mobile Device Development MVP

        C Offline
        C Offline
        Chetan Ranpariya
        wrote on last edited by
        #3

        Hi Joel, Thanks for the reply. I tried the tip you mentioned. I am currently running the application on device emulators. I changed the date time information of the emulator to my system date time but it didn't work. The web service I m consuming is in different timezone, and I tried to change the emulator datetime information to that timezone too, but that also didn't help me. I event asked the service providers but according to them there is nothing changed from their side except the service url which I am currently using. If I refer the same service url in a windows desktop application, everything works fine. I am really stuck. Please help me.

        Thanks and Regards, Chetan Ranpariya

        1 Reply Last reply
        0
        • C Chetan Ranpariya

          Hi Friends, I am developing a Windows Mobile application using 6.0 professional SDK. Here I am consuming a web service which is hosted on HTTPS. I am able to add the web reference successfully but when I call a method of the service using proxy it throws following exception. "Could not establish trust relationship with remote server." The same scenario works fine if I test it with a desktop windows application. I am able to call the method successfully and I receive the response too, but I dont know why it is not working with Windows Mobile. I am able to browse the websites from the mobile browser so there is no issue about the connection. Please help me soon friends I m running out of time...I have search all over the world during last 2 days but could not find any satisfactory and working solution. Thank you all in advance.

          Thanks and Regards, Chetan Ranpariya

          C Offline
          C Offline
          Chetan Ranpariya
          wrote on last edited by
          #4

          Hi friends, Finally I found the solution of this problem. I had to create a class which implemented ICertificatePolicy interface as following.

          public class AlwaysTrustedCertificatePolicy : ICertificatePolicy
          {
          #region ICertificatePolicy Members
          public bool CheckValidationResult(ServicePoint srvPoint,
          System.Security.Cryptography.X509Certificates.X509Certificate certificate,
          WebRequest request,
          int certificateProblem)
          {
          return true;
          }
          #endregion
          }

          And before calling the first ever method of service I created an instance of this class and assign it to "CertificatePolicy" of "ServicePointManager" class.

          ICertificatePolicy certificatePolicy = new new AlwaysTrustedCertificatePolicy();

          ServicePointManager.CertificatePolicy = certificatePolicy;

          var serviceClient = new ServiceClient();

          serviceClient.Login(username, password);

          This worked for me very well... but this is I guess work around not the proper solution. If any body finds the solution please post.

          Thanks and Regards, Chetan Ranpariya

          1 Reply Last reply
          0
          • J Joel Ivory Johnson

            The first thing I would check is the date and time on your Windows Phone. It it is wrong then SSL authentication will fail.


            Joel Ivory Johnson

            J2i.net | @J2iNet | Mobile Device Development MVP

            J Offline
            J Offline
            Justin Stolle
            wrote on last edited by
            #5

            Dude! I tried this (setting the correct date/time) out of desperation after continually having a "Could not establish trust relationship with remote server" error message and it flippin' worked. Thanks for the tip--why can't these error messages give a little more information????

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups