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. General Programming
  3. C / C++ / MFC
  4. CInternetSession: https certificate problem

CInternetSession: https certificate problem

Scheduled Pinned Locked Moved C / C++ / MFC
helpjavacomcryptographyquestion
4 Posts 2 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.
  • M Offline
    M Offline
    msn92
    wrote on last edited by
    #1

    Hello everybody. This is my problem: I need to connect to https webpage which has a self-signed certificate. Regular webbrowsers warn me when I open that page. I want to connect to it and POST some data. When I connect to the https webpage, I'm getting an error saying "The certificate authority is invalid or incorrect". Here's my code:

    CInternetSession ises;
    CFile* f=NULL;
    f=(CFile*)ises.OpenURL(L"https://mysite.com/login.jsp"); //I get the error here
    ...

    Is there any way to accept that certificate or any other solution? Thanks in advance.

    C 1 Reply Last reply
    0
    • M msn92

      Hello everybody. This is my problem: I need to connect to https webpage which has a self-signed certificate. Regular webbrowsers warn me when I open that page. I want to connect to it and POST some data. When I connect to the https webpage, I'm getting an error saying "The certificate authority is invalid or incorrect". Here's my code:

      CInternetSession ises;
      CFile* f=NULL;
      f=(CFile*)ises.OpenURL(L"https://mysite.com/login.jsp"); //I get the error here
      ...

      Is there any way to accept that certificate or any other solution? Thanks in advance.

      C Offline
      C Offline
      Code o mat
      wrote on last edited by
      #2

      Maybe this[^] can help.

      > The problem with computers is that they do what you tell them to do and not what you want them to do. < > "It doesn't work, fix it" does not qualify as a bug report. < > Amazing what new features none of the programmers working on the project ever heard of you can learn about when reading what the marketing guys wrote about it. <

      M 1 Reply Last reply
      0
      • C Code o mat

        Maybe this[^] can help.

        > The problem with computers is that they do what you tell them to do and not what you want them to do. < > "It doesn't work, fix it" does not qualify as a bug report. < > Amazing what new features none of the programmers working on the project ever heard of you can learn about when reading what the marketing guys wrote about it. <

        M Offline
        M Offline
        msn92
        wrote on last edited by
        #3

        Code-o-mat, thanks for your reply. I tried the code that should ignore the invalid certifacate as said in the link you gave. But, it doesn't seem to work, the code's working, but my problem didn't get solved. Please see the code:

        CFile* f=NULL;
        MyTry:
        try{
        f=(CFile*)ises.OpenURL(L"https://mysite.com/login.jsp");
        }
        catch(CInternetException* s){
        if(s->m_dwError==ERROR_INTERNET_INVALID_CA){
        DWORD dwFlags;
        DWORD dwBufferLen=sizeof(dwFlags);
        ises.QueryOption(INTERNET_OPTION_SECURITY_FLAGS,(LPVOID)&dwFlags,&dwBufferLen);
        dwFlags|=SECURITY_FLAG_IGNORE_UNKNOWN_CA|SECURITY_FLAG_IGNORE_CERT_CN_INVALID;
        ises.SetOption(INTERNET_OPTION_SECURITY_FLAGS,&dwFlags,sizeof(dwFlags));
        goto MyTry;
        }
        }
        ...

        Is there any other way to workaround this problem?

        C 1 Reply Last reply
        0
        • M msn92

          Code-o-mat, thanks for your reply. I tried the code that should ignore the invalid certifacate as said in the link you gave. But, it doesn't seem to work, the code's working, but my problem didn't get solved. Please see the code:

          CFile* f=NULL;
          MyTry:
          try{
          f=(CFile*)ises.OpenURL(L"https://mysite.com/login.jsp");
          }
          catch(CInternetException* s){
          if(s->m_dwError==ERROR_INTERNET_INVALID_CA){
          DWORD dwFlags;
          DWORD dwBufferLen=sizeof(dwFlags);
          ises.QueryOption(INTERNET_OPTION_SECURITY_FLAGS,(LPVOID)&dwFlags,&dwBufferLen);
          dwFlags|=SECURITY_FLAG_IGNORE_UNKNOWN_CA|SECURITY_FLAG_IGNORE_CERT_CN_INVALID;
          ises.SetOption(INTERNET_OPTION_SECURITY_FLAGS,&dwFlags,sizeof(dwFlags));
          goto MyTry;
          }
          }
          ...

          Is there any other way to workaround this problem?

          C Offline
          C Offline
          Code o mat
          wrote on last edited by
          #4

          I can't think of anything else other than trying to do the download without OpenURL, using CInternetSession::GetHttpConnection[^], CHttpConnection::OpenRequest[^] and CHttpFile[^], maybe it makes a difference...

          > The problem with computers is that they do what you tell them to do and not what you want them to do. < > "It doesn't work, fix it" does not qualify as a bug report. < > Amazing what new features none of the programmers working on the project ever heard of you can learn about when reading what the marketing guys wrote about it. <

          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