简体   繁体   English

我可以对HTTPS请求使用boost asio吗

[英]Can I use boost asio for HTTPS requests

Can I use boost asio for HTTPS requests? 我可以对HTTPS请求使用boost asio吗? I can make GET and POST HTTP requests, but what about HTTPS? 我可以发出GET和POST HTTP请求,但是HTTPS呢? How can I handle it? 我该如何处理? Can somebody provide me a code snippet? 有人可以给我代码片段吗?

Yes you can. 是的你可以。 http://www.boost.org/doc/libs/1_47_0/doc/html/boost_asio/example/ssl/client.cpp Simply integrate it to your HTTP request. http://www.boost.org/doc/libs/1_47_0/doc/html/boost_asio/example/ssl/client.cpp只需将其集成到您的HTTP请求中即可。

Asio offers basic SSL support through OpenSSL. Asio通过OpenSSL提供基本的SSL支持 A code example is available as part of the documentation 文档中提供了代码示例

In general, HTTPS is quite similar to HTTP, except for the fact that you have to perform an SSL handshake to initialize the connection. 通常,HTTPS与HTTP非常相似,不同之处在于您必须执行SSL握手来初始化连接。 Asio offers an implementation for this. Asio为此提供了一个实现

The actual communication is quite easy, as you simply encrypt your HTTP stream, the actual communication patterns are the same. 实际的通信非常容易,因为您只需加密HTTP流,实际的通信模式是相同的。

Therefore, if the functionality offered by Asio is not flexible enough, you can also write your own encryption layer on top of Asio using OpenSSL (although I would not recommend this unless you already have a fair deal of experience with encryption). 因此,如果Asio提供的功能不够灵活,您还可以使用OpenSSL在Asio之上编写自己的加密层(尽管除非您已有相当丰富的加密经验,否则我不建议您这样做)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM