我遇到的问题与卡萨布兰卡c++时,使用https在它的url
I am running into issues with Casablanca C++ when using urls with https in it
我们使用Resource Owner Credentials
来使用内部OAuth Svr
获得访问令牌。如果url中不包含任何https,则一切正常,但当我在其中包含https时,一切都失败了。
我们用https
部署了我们所有的站点:
后面是一个非常简单的失败代码。我没有任何线索,为什么我得到例外,如果我包括https
在它。
try
{
http_client api(U("https://172.27.12.207/AuthSvr"), m_http_config);
ucout << "Requesting account information:" << std::endl;
ucout << "Information: " << api.request(methods::GET, U("identity/.well-known/openid-configuration")).get().extract_json().get() << std::endl;
//TestRestAPI().wait();
}
catch (...)
{
ucout << "Unknown Error";
}
编辑
我处理异常捕获web::http::http_exception
,我看到错误:
WinHttpSendRequest: 12175: A security error occurred
在尝试验证自签名证书时出现该问题。这通常出现在开发中,没有使用有效的证书,而是生成了一个动态证书。
可以通过禁用验证来解决这个问题。
web::http::client::http_client_config config;
config.set_validate_certificates(false);
auto client = std::make_shared<web::http::client::http_client>(U("https://localhost:8081/"), config);
请确保这只是在调试测试代码中完成的,而不是最终产品的一部分。
//创建一个HTTP请求句柄。shRequest = WinHttpOpenRequest (shConnect, L"GET", L"/robots.txt",空,WINHTTP_NO_REFERER,WINHTTP_DEFAULT_ACCEPT_TYPES,0);//WINHTTP_FLAG_SECURE);
在我的情况下,通过注释WINHTTP_FLAG_SECURE标志解决了类似的问题。
相关文章:
- 如何使用野兽C++库从HTTP重定向到HTTPS?
- 我可以使用 Boost.Asio 和 Boost.Beast 库发出 HTTPS 请求或 HTTP/2 请求吗?
- QT如何使用SSL发送https
- 使用带有SSL(HTTPS)的Boost-Beast(ASIO)HTTP客户端
- 如何使用 libtins 捕获 HTTPS 数据包
- 如何将HTTPS与Qt网络一起使用
- Qnetworkreply,QnetworkAccessManager- https下载文件 - 高CPU使用情况
- C++ 使用 Curl 库编程 - 抛出错误"protocol https not supported or disabled."
- 使用Winsock2向具有域HTTPS的Webstie发送GET请求
- https在c/c 中使用linux上的openssl
- 使用 boost::asio 连接到 HTTPS 服务器
- 使用 qt creator 在带有 https 的网站上获取一些值
- 使用CURL从HTTPS连接未获取任何内容
- 在Visual Studio中使用Libcurl发出HTTPS请求时遇到问题
- 我可以对HTTPS请求使用boost asio吗
- 使用Qt在Linux上实现了一个C++HTTPS SOAP客户端
- 使用poco库构建HTTPS服务器时出错
- 使用 libcurl 编写 HTTPS SOAP 客户端
- 使用Poco在c++中进行HTTPS请求
- web服务- json-rpc服务器通过HTTPS使用c++