curl
使用类似或 之类的工具wget
很容易“获取”HTTP GET 请求的响应,但这两个工具默认情况下都没有安装在 OpenBSD 上,并且编写可移植的 shell 脚本,不能假设它们安装在另一台计算机上。
我想要一种“安全”的方式来获取服务器响应(例如维基百科.org)使用工具进入我的终端是默认安装。安全意味着响应不应是明文,而应在发送到我的计算机时使用 HTTP/2 和 TLS 1.3/TLS 1.2(当然,如果服务器支持)等当前标准进行加密。
答案1
您无需指定是否需要标头、响应代码或有关 TLS 协议的详细信息。
正如已经回答的那样,您可以使用ftp
.-d
打开开关可以ftp
为您提供有关 HTTP(S) 级别的大量信息:
$ ftp -d -o /dev/null https://en.wikipedia.org
host en.wikipedia.org, port https, path , save as /dev/null, auth none.
Trying 91.198.174.192...
Requesting https://en.wikipedia.org
GET / HTTP/1.1
Connection: close
Host: en.wikipedia.org
User-Agent: OpenBSD ftp
received 'HTTP/1.1 301 Moved Permanently'
received 'Date: Thu, 03 Mar 2022 10:42:56 GMT'
received 'Server: mw1324.eqiad.wmnet'
received 'X-Content-Type-Options: nosniff'
received 'P3p: CP="See https://en.wikipedia.org/wiki/Special:CentralAutoLogin/P3P for more info."'
received 'Vary: Accept-Encoding,X-Forwarded-Proto,Cookie,Authorization'
received 'Cache-Control: s-maxage=1200, must-revalidate, max-age=0'
received 'Last-Modified: Thu, 03 Mar 2022 10:42:56 GMT'
received 'Location: https://en.wikipedia.org/wiki/Main_Page'
Redirected to https://en.wikipedia.org/wiki/Main_Page
host en.wikipedia.org, port https, path wiki/Main_Page, save as /dev/null, auth none.
Trying 91.198.174.192...
Requesting https://en.wikipedia.org/wiki/Main_Page
GET /wiki/Main_Page HTTP/1.1
Connection: close
Host: en.wikipedia.org
User-Agent: OpenBSD ftp
received 'HTTP/1.1 200 OK'
received 'Date: Thu, 03 Mar 2022 07:48:57 GMT'
received 'Server: mw1393.eqiad.wmnet'
received 'X-Content-Type-Options: nosniff'
received 'P3p: CP="See https://en.wikipedia.org/wiki/Special:CentralAutoLogin/P3P for more info."'
received 'Content-Language: en'
received 'Vary: Accept-Encoding,Cookie,Authorization'
received 'Last-Modified: Thu, 03 Mar 2022 07:48:56 GMT'
received 'Content-Type: text/html; charset=UTF-8'
received 'Age: 11005'
received 'X-Cache: cp3052 hit, cp3058 hit/120231'
received 'X-Cache-Status: hit-front'
received 'Server-Timing: cache;desc="hit-front", host;desc="cp3058"'
received 'Strict-Transport-Security: max-age=106384710; includeSubDomains; preload'
received 'Report-To: { "group": "wm_nel", "max_age": 86400, "endpoints": [{ "url": "https://intake-logging.wikimedia.org/v1/events?stream=w3c.reportingapi.network_error&schema_uri=/w3c/reportingapi/network_error/1.0.0" }] }'
received 'NEL: { "report_to": "wm_nel", "max_age": 86400, "failure_fraction": 0.05, "success_fraction": 0.0}'
received 'Permissions-Policy: interest-cohort=()'
received 'Set-Cookie: WMF-Last-Access=03-Mar-2022;Path=/;HttpOnly;secure;Expires=Mon, 04 Apr 2022 00:00:00 GMT'
received 'Set-Cookie: WMF-Last-Access-Global=03-Mar-2022;Path=/;Domain=.wikipedia.org;HttpOnly;secure;Expires=Mon, 04 Apr 2022 00:00:00 GMT'
received 'X-Client-IP: 148.69.164.57'
received 'Cache-Control: private, s-maxage=0, max-age=0, must-revalidate'
received 'Set-Cookie: GeoIP=PT:06:Coimbra:40.21:-8.42:v4; Path=/; secure; Domain=.wikipedia.org'
received 'Accept-Ranges: bytes'
received 'Content-Length: 84542'
received 'Connection: close'
100% |*******************************************************************************************************************************************************| 84542 00:00
84542 bytes received in 0.22 seconds (368.47 KB/s)
有关 TLS 的更多具体信息,我将使用openssl
,它也在基本系统上:
$ openssl s_client -connect en.wikipedia.org:443 < /dev/null
(...)
New, TLSv1/SSLv3, Cipher is TLS_AES_256_GCM_SHA384
Server public key is 256 bit
Secure Renegotiation IS NOT supported
Compression: NONE
Expansion: NONE
No ALPN negotiated
SSL-Session:
Protocol : TLSv1.3
Cipher : TLS_AES_256_GCM_SHA384
Session-ID:
Session-ID-ctx:
Master-Key:
Start Time: 1646305125
Timeout : 7200 (sec)
Verify return code: 0 (ok)
---
DONE
答案2
base 中的工具ftp
可以执行 HTTP 和 HTTPS。