CInternetSession: https certificate problem
-
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.
-
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.
> 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. <
-
> 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. <
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?
-
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?
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. <