curl - 使用 POST 向服务器发送信息不适用于 curl 但适用于 netcat
问题描述
我有一个用 python 编写的小脚本,它充当服务器,仅在端口 443 上侦听应相应格式化的 POST 请求(这是文件的内容:testfile):
POST //[authority]/[path] HTTP/1.1
Host: [authority]
Content-length: [length]
[message-body]
当我尝试使用 netcat 发布 CSR 请求时,一切正常:
# ncat -v --ssl 192.168.0.1 443 < testfile
Ncat: Version 7.50 ( https://nmap.org/ncat )
Ncat: Subject: CN=test-server
Ncat: Issuer: CN=test-server
Ncat: SHA-1 fingerprint: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Ncat: Certificate verification failed (self signed certificate).
Ncat: SSL connection to 192.168.0.1:443.
Ncat: SHA-1 fingerprint: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
HTTP/1.1 200 OK
text/html; charset=UTF-8
CSR file name: /opt/xxxx/xxx-xxx/xxx-queue/xxxxxxxxxxxxxxxxxxxxxxxxxxxxx.pem.csr
<h4>SUCCESS - CSR was uploaded, verified and stored</h4>
Ncat: 849 bytes sent, 199 bytes received in 0.02 seconds.
当我尝试使用 curl 进行操作时,它正在等待回复:
# curl -vkl -X POST \
-H "User-Agent: " -H "Accept: " -H "Host: xxxx" \
-H "Content-length: 688" -H "Expect: " -H "Content-Type: " \
-d @testfile https://192.168.0.1/
* About to connect() to 192.168.0.1 port 443 (#0)
* Trying 192.168.0.1...
* Connected to 192.168.0.1 (192.168.0.1) port 443 (#0)
* Initializing NSS with certpath: sql:/etc/pki/nssdb
* skipping SSL peer certificate verification
* SSL connection using TLS_RSA_WITH_AES_128_CBC_SHA
* Server certificate:
* subject: CN=test-server
* start date: Apr 29 20:29:49 2018 GMT
* expire date: Apr 26 20:29:49 2028 GMT
* common name: test-server
* issuer: CN=-test-server
> POST / HTTP/1.1
> Host: xxxxxxxxxx
> Content-length: 688
>
* upload completely sent off: 676 out of 676 bytes
它挂在这条消息上。不知道为什么。
请帮帮我。谢谢。
解决方案
推荐阅读
- java - JAVA 和 PYTHON 中的 SHA256 加密产生不同的结果
- xml - XSLT - 递归循环基本案例
- docker - Docker 镜像 gcr.io/google_containers/kube2sky:1.15 源码位置
- c# - 使用access数据库将用户登录数据从form1传递到form2 listview
- sparql - Wikimedia Commons:获取子类别的名称(使用 SPARQL 或 MediaWiki API)
- javascript - 多组复选框要求每个组至少有 1 个
- ckan - CKAN 测试错误:“KeyError: 'tags'”
- r - 如何运行 pgmm 命令?
- java - LoadLibrary 失败 RJava
- c# - 保护 .NET Core 2.1 与 SQL Azure 数据库对话的应用程序设置中的连接字符串