- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在搜索 C++ 中的客户端 TLS 连接示例。最适合 Visual Studio,但老实说它可以是任何编译器。我找到了几个 C 样本。但是没有人工作。我从 C 中的这个示例开始: https://wiki.openssl.org/index.php/SSL/TLS_Client
但是失败了
res = BIO_do_connect(web);
如果我想连接到我自己的 node.js 服务器(使用直接 ip 地址)或使用 encrypted.google.com 作为 url 的“错误主机名查找”,则使用“系统库”。都使用 libressl 和 Visual Studio 2013。
下一站:http://fm4dd.com/openssl/sslconnect.htm
到这里程序运行成功。但是任何尝试在最后写入 SSL 连接:
std::string json = "{'test':'huhu'}";
char buff[1024];
sprintf(buff, "POST /test.de HTTP/1.1 \nHost: test.de\nContent-Type: application/json\nContent-Length: %d\n\n", json.length());
std::string post = buff;
int snd = SSL_write(ssl, post.data(), post.length());
snd = SSL_write(ssl, json.data(), json.length());
强制服务器关闭连接(我不知道到底发生了什么,因为我现在不知道如何告诉 node.js 告诉我更多信息)。
所以我搜索了一个工作示例或如何使用在 C++ 中运行的自己的证书获得 TLS 连接
最佳答案
I am searching for a client TLS connection example in C++.
我认为有几个 OpenSSL 到 C++ 的端口。他们尝试做完整的类包装器。参见 openssl++ class在谷歌上。
当我在 C++ 中使用它时,我使用唯一指针进行清理。参见,例如,How to properly print RSA* as string in C++? .我主要使用它来确保清理。我认为它类似于Resource Acquisition Is Initialization模式。
OpenSSL 还为类似的库和框架提供了一个页面。查看Related Links OpenSSL wiki 上的页面。
But it fails on
res = BIO_do_connect(web);
with "system library" if I want to connect to my own node.js server (using the > direct ip address) or with "bad hostname lookup"
我的猜测是证书中的名称与连接 URL 中使用的名称不匹配。
您可以通过在 host
文件中添加一个条目来使名称起作用。实际上,这是您的本地 DNS 覆盖。参见 Microsoft TCP/IP Host Name Resolution Order .
或者,您可以生成包含所有必需名称的证书。为此,请参阅 How to create a self-signed certificate with openssl?
forces the server to close the connection (I do not see exactly what happend as I do not now how I can tell node.js to tell me more).
"POST /test.de HTTP/1.1 \nHost: test.de\nContent-Type:
application/json\nContent-Length: %d\n\n"
由于您缺少 Connection: close
请求 header ,服务器可能正在跟踪 RFC 7230, HTTP/1.1 Message Syntax and Routing, Section 6.1 :
A server that does not support persistent connections MUST send the"close" connection option in every response message that does nothave a 1xx (Informational) status code.
另外,那应该是:
"POST /test.de HTTP/1.1\r\nHost: test.de\r\nContent-Type:
application/json\r\nContent-Length:%d\r\n\r\n"
\r\n
用作新行,不是 \r
也不是 \n
。双 \r\n
用于终止 header 。您可以快速验证是否在标准中搜索 “CRLF”。您将参与 ABNF 语法的讨论。
So I search for a working sample or how to get a TLS connection with own certificate running in C++
这里的技巧是创建格式正确的证书。为此,请参阅 How to create a self-signed certificate with openssl?
关于c++ - 用于客户端 TLS 连接的 OpenSSL 或 LibreSSL C++ 示例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29987200/
是否可以使用 OpenSSL 或其他工具通过 TLS 建立 TLS 连接? 如果可能,每个级别的证书是否需要不同? 最佳答案 这在理论上应该工作得很好,但我不能确定 OpenSSL 或其他东西是否会轻
在我的 java 代码中,我正在使用命令创建 SSL 上下文的一个实例 SSLContext ctx = SSLContext.getInstance("TLS"); 但是在我的 tomcat 服务器
在我的 java 代码中,我正在使用命令创建一个 SSL 上下文实例 SSLContext ctx = SSLContext.getInstance("TLS"); 但在我的 tomcat 服务器中,
范围:这是一个具有一个 channel 的网络,该 channel 由 3 个组织组成,每个组织 1 个 anchor 节点,每个组织 1 个 CA 和每个组织 1 个 MSP。 我在我的 Hyper
无法找到用于在 iis 上启用/禁用 tls 的特定设置。启用/禁用 ssl 是否与启用/禁用 tls 相同? 我浏览了一些博客,发现 SSL 是 TLS 的前身,旧版本的 SSL 已被弃用。但我无法
最近,我一直在为基于物联网的项目评估不同的 API 网关 (API GW) 选项。这样做的目的是找到一个足够好的解决方案来执行设备和 API GW 的相互 TLS (mTLS) 身份验证。 我尝试过的
几个月来,我的 Web 应用程序在不同版本的 IE/Firefox/Chrome 上运行良好。我的应用程序在 IIS 10.0 上运行。当我从 Windows 7 框 (IE 11.0.***) 中点
我有一个在 Java 7 上运行的 HTTPS 网络服务。我需要进行更改,以便此服务仅接受 TLS1.2 连接并拒绝 SSL3、TLS1.0 和 TLS1.1。 我添加了以下 Java 参数,使 TL
我在资源管理器不显示网站时遇到问题:“无法显示此页面。在高级设置中打开 TLS 1.0、TLS 1.1 和 TLS 1.2”。 我在 chrome 中调试了证书并说“连接是使用 aes_128_cbc
我正在与 5 个订购者、1 个组织和 2 个同行建立我的网络。还有 1 个 cli 和 1 个 ca。 我从 1 个排序者扩展到 5 个实现 Raft 的排序者。这就是为什么我想扩展我的网络并对多个对
当k8s集群开启了TLS认证后,每个节点的kubelet组件都要使用由kube-apiserver的CA签发的有效证书才能与kube-apiserver通信;当节点非常多的时候,为每个节点都单独签署证
我正在尝试使用 pjsip 安装中的 pjsua 程序在两个虚拟机之间进行安全调用。我通过以下方式在每个节点上启动程序: pjsua-x86_64-unknown-linux-gnu --use-tl
我开发的软件应用程序使用 gRPC 在客户端和服务器之间建立双向流。 我只在 java 中寻找类似于这张票的答案的东西:How to enable server side SSL for gRPC?
我正在尝试调试与 TLS 相关的问题。TLS 在两个应用程序客户端 A 和服务器 B 之间设置。A 和 B 都交换了证书,我已经验证证书具有正确的扩展名,并且还通过其根 CA 成功验证。叶证书的根 C
“Java 1.7 TLS 1.1 服务器”和“Java 1.8 客户端”之间的 SSL/TLS 握手在我的环境中失败,服务器端出现以下异常: java.security.NoSuchAlgorith
我正在尝试了解 Docker ,但我不断收到神秘的(对我而言)错误消息。 可能最简单的例子是尝试打印我安装的 Docker 版本: $ sudo docker version Client versi
这是我第一次使用 Amazon Lighsail、Wordpress Multisite、Bitnami甚至使用 Let's Encrypt;现在似乎一切正常,除了我的虚拟主机文件中的 SSL 指令。
我有一个 MariaDB "M"。在同一台机器上有一个应用程序“A”,它可以访问它。在不同的服务器上,另一个应用程序“B”也在访问它。 现在我想在 MariaDB 上启用 TLS 以保护连接 B ->
我正在寻找通过代理连接到一些 HTTPS/TLS 站点,其中到代理本身的连接也是通过 HTTPS/TLS 建立的,来自一个高度依赖请求的 python 应用程序。 urllib3(因此 request
现在我正在努力改变 EMQtt 和 Erlang MQTT 代理,以便我可以使用预共享 key 而不是非对称方法执行 TLS 握手。 到目前为止,我几乎遍历了源代码中的每个文件,但找不到任何加密函数。
我是一名优秀的程序员,十分优秀!