Discussion:
InternetOpenURL and HTTPS url
(too old to reply)
a***@gmail.com
2006-09-15 14:36:44 UTC
Permalink
Im trying to access a page using InternetOpenURL
everythgin works fine for http urls however as soon as Ulr is https
i get ERROR_INTERNET_INVALID_CA
I tryed ms described method (Setting internetoptions for the HINTERNET
handle returned by
InternetConenct call but that did not help

is there a way to ignore invalid_ca on internetopenurl calls ?


_again:
hFile =
InternetOpenUrl(hINet,sUri.c_str(),NULL,0,INTERNET_FLAG_SECURE,0);
if (!hFile)
{
if (GetLastError() == ERROR_INTERNET_INVALID_CA)
{
DWORD dwFlags = 0;
DWORD dwBuffLen = sizeof(dwFlags);

InternetQueryOption (hINet, INTERNET_OPTION_SECURITY_FLAGS,
(LPVOID)&dwFlags, &dwBuffLen);

dwFlags |= SECURITY_FLAG_IGNORE_UNKNOWN_CA;
dwFlags |= SECURITY_FLAG_IGNORE_CERT_CN_INVALID;
dwFlags |= SECURITY_FLAG_IGNORE_CERT_DATE_INVALID;

InternetSetOption (hINet, INTERNET_OPTION_SECURITY_FLAGS,
&dwFlags, sizeof (dwFlags) );
goto _again;
//hFile =
InternetOpenUrl(hINet,sUri.c_str(),NULL,0,INTERNET_FLAG_IGNORE_CERT_CN_INVALID,0);
//if (!hFile)
// goto _stop;
//else
// goto _cont;
}
_stop:
Vladimir Scherbina
2006-09-15 19:16:26 UTC
Permalink
Aris,

Use INTERNET_FLAG_IGNORE_CERT_CN_INVALID flag as written in KB article:
http://support.microsoft.com/default.aspx?scid=kb;en-us;168151
--
Vladimir
Post by a***@gmail.com
Im trying to access a page using InternetOpenURL
everythgin works fine for http urls however as soon as Ulr is https
i get ERROR_INTERNET_INVALID_CA
I tryed ms described method (Setting internetoptions for the HINTERNET
handle returned by
InternetConenct call but that did not help
is there a way to ignore invalid_ca on internetopenurl calls ?
hFile =
InternetOpenUrl(hINet,sUri.c_str(),NULL,0,INTERNET_FLAG_SECURE,0);
if (!hFile)
{
if (GetLastError() == ERROR_INTERNET_INVALID_CA)
{
DWORD dwFlags = 0;
DWORD dwBuffLen = sizeof(dwFlags);
InternetQueryOption (hINet, INTERNET_OPTION_SECURITY_FLAGS,
(LPVOID)&dwFlags, &dwBuffLen);
dwFlags |= SECURITY_FLAG_IGNORE_UNKNOWN_CA;
dwFlags |= SECURITY_FLAG_IGNORE_CERT_CN_INVALID;
dwFlags |= SECURITY_FLAG_IGNORE_CERT_DATE_INVALID;
InternetSetOption (hINet, INTERNET_OPTION_SECURITY_FLAGS,
&dwFlags, sizeof (dwFlags) );
goto _again;
//hFile =
InternetOpenUrl(hINet,sUri.c_str(),NULL,0,INTERNET_FLAG_IGNORE_CERT_CN_INVALID,0);
//if (!hFile)
// goto _stop;
//else
// goto _cont;
}
Loading...