12038 ERROR_INTERNET_SEC_CERT_CN_INVALID
SSL certificate common name (host name field) is incorrect.
For example, if you entered http://www.server.com and the common
name on the certificate says http://www.different.com.
Looks like that using INTERNET_FLAG_IGNORE_CERT_CN_INVALID works fine.
Don’t know if this should be added by default to match OSX behavior
My bad, OSX fails as well.
I was tricked as the stream returned was not NULL, but actually the returned stream contains the text corresponding to the Windows error.
So better to remove your modifications from the Windows code.