易语言 使用WinHttp对象访问证书错误的网站

winhttp对象本身支持https

但是今天遇到个网站,证书错误,然后用winhttp访问 返回空

查找一番,发现winhttp有个属性 winhttprequestoption_sslerrorignoreflags ,就是忽略证书错误标志,只要将此标志设置为 SslErrorFlag_Ignore_All (13056) 就可以了

http.option(4,13056)


附上winhttp的一些可设置选项,以备后用:

Option()相关:
WinHttpRequestOption_UserAgentString = 0;
WinHttpRequestOption_URL = 1;
WinHttpRequestOption_URLCodePage = 2;
WinHttpRequestOption_EscapePercentInURL = 3;
WinHttpRequestOption_SslErrorIgnoreFlags = 4;
WinHttpRequestOption_SelectCertificate = 5;
WinHttpRequestOption_EnableRedirects = 6;      
WinHttpRequestOption_UrlEscapeDisable = 7;
WinHttpRequestOption_UrlEscapeDisableQuery = 8;
WinHttpRequestOption_SecureProtocols = 9;
WinHttpRequestOption_EnableTracing = 10;
WinHttpRequestOption_RevertImpersonationOverSsl = 11;
WinHttpRequestOption_EnableHttpsToHttpRedirects = 12;
WinHttpRequestOption_EnablePassportAuthentication = 13;
WinHttpRequestOption_MaxAutomaticRedirects = 14;
WinHttpRequestOption_MaxResponseHeaderSize = 15;
WinHttpRequestOption_MaxResponseDrainSize = 16;
WinHttpRequestOption_EnableHttp1_1 = 17;
WinHttpRequestOption_EnableCertificateRevocationCheck = 18;


Enum WinHttpRequestAutoLogonPolicy;
  AutoLogonPolicy_Always = 0;
  AutoLogonPolicy_OnlyIfBypassProxy = 1;
  AutoLogonPolicy_Never = 2;

Enum WinHttpRequestSslErrorFlags;
  SslErrorFlag_UnknownCA = 0x100;
  SslErrorFlag_CertWrongUsage = 0x200;
  SslErrorFlag_CertCNInvalid = 0x1000;
  SslErrorFlag_CertDateInvalid = 0x2000;
  SslErrorFlag_Ignore_All = 0x3300;

Enum WinHttpRequestSecureProtocols;
  SecureProtocol_SSL2 = 8;
  SecureProtocol_SSL3 = 32;
  SecureProtocol_TLS1 = 128;
  SecureProtocol_ALL = 168;



你可能感兴趣的:(易语言)