Client authentication (certificat + private key) using WinInet

点点圈 提交于 2019-11-29 15:51:56

You have to pass your certificate to WinInet using INTERNET_OPTION_CLIENT_CERT_CONTEXT with a call to InternetSetOption():

INTERNET_OPTION_CLIENT_CERT_CONTEXT

84

This flag is not supported by InternetQueryOption. The lpBuffer parameter must be a pointer to a CERT_CONTEXT structure and not a pointer to a CERT_CONTEXT pointer. If an application receives ERROR_INTERNET_CLIENT_AUTH_CERT_NEEDED, it must call InternetErrorDlg or use InternetSetOption to supply a certificate before retrying the request. CertDuplicateCertificateContext is then called so that the certificate context passed can be independently released by the application.

So, for example:

InternetSetOption(hI,INTERNET_OPTION_CLIENT_CERT_CONTEXT,(void*)cert,sizeof(CERT_CONTEXT));

Btw, curl calls are not good examples because curl uses libcurl which uses OpenSSL.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!