我正在 Google Cloud 實體上安裝 OpenVPN 訪問服務器。它的 webUI 使用 https 偵聽埠 943。它有一個自簽名證書,其名稱與服務器的主機名 (10.150.0.2) 不匹配。我無法啟動 SSH 隧道。我正在尋找一種方法來解決從 IAP 服務到我的服務器的連接問題。
我正在運行的命令是gcloud compute start-iap-tunnel vpn 943 --local-host-port=localhost:943我收到正常Testing if tunnel connection works訊息。
它出錯了 ERROR: (gcloud.compute.start-iap-tunnel) While checking if a connection can be made: Error while connecting [4003: 'failed to connect to backend']. (Failed to connect to port 943)
如果我添加--log-http到命令呼叫中,相關資訊如下(它看起來像一個正常的 req/resp 回圈,我假設是從我的客戶端到 IAP 服務的 200):
Testing if tunnel connection works.
=======================
==== request start ====
uri: https://oauth2.googleapis.com/token
method: POST
== headers start ==
b'content-type': b'application/x-www-form-urlencoded'
b'user-agent': b'google-cloud-sdk gcloud/367.0.0 command/gcloud.compute.start-iap-tunnel invocation-id/db27de82264f47fcb63f6680afaa8327 environment/None environment-version/None interactive/False from-script/False python/3.7.9 term/xterm-256color (Macintosh; Intel Mac OS X 21.2.0)'
== headers end ==
== body start ==
Body redacted: Contains oauth token. Set log_http_redact_token property to false to print the body of this request.
== body end ==
==== request end ====
---- response start ----
status: 200
-- headers start --
Alt-Svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43"
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Content-Encoding: gzip
Content-Type: application/json; charset=utf-8
Date: Fri, 24 Dec 2021 02:11:52 GMT
Expires: Mon, 01 Jan 1990 00:00:00 GMT
Pragma: no-cache
Server: scaffolding on HTTPServer2
Transfer-Encoding: chunked
Vary: Origin, X-Origin, Referer
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 0
-- headers end --
-- body start --
Body redacted: Contains oauth token. Set log_http_redact_token property to false to print the body of this response.
-- body end --
total round trip time (request response): 0.246 secs
---- response end ----
----------------------
ERROR: (gcloud.compute.start-iap-tunnel) While checking if a connection can be made: Error while connecting [4003: 'failed to connect to backend']. (Failed to connect to port 943)
據我所知,這是start-tap-tunnel.
轉到本地機器,我們可以在生成 la 證書之前連接到 10.150.0.2:943。
root@viongier:/usr/local/openvpn_as# wget https://10.150.0.2:943
--2021-12-24 02:01:47-- https://10.150.0.2:943/
Connecting to 10.150.0.2:943... connected.
ERROR: The certificate of ‘10.150.0.2’ is not trusted.
ERROR: The certificate of ‘10.150.0.2’ doesn't have a known issuer.
The certificate's owner does not match hostname ‘10.150.0.2’
在我看來,我的客戶端很高興連接到無法連接到我的服務器的 IAP 服務。如果由于證書而出錯,我希望看到 IAP 錯誤。我能想到的唯一測驗方法是生成一個證書,其頒發者 google 喜歡。(例如讓我們加密。)
uj5u.com熱心網友回復:
此訊息表示后端沒有處于偵聽狀態的套接字打開。常見的原因是沒有啟動任何服務或防火墻阻止了埠。
要允許身份感知代理進入您的 VPC,請允許來自35.235.240.0/20 的流量。
錯誤:(gcloud.compute.start-iap-tunnel) 在檢查是否可以建立連接時:連接時出錯 [4003:'無法連接到后端']。(無法連接到埠 943)
此錯誤意味著提供的證書與建立連接的地址不匹配:
錯誤:“10.150.0.2”的證書不受信任。錯誤:“10.150.0.2”的證書沒有已知的頒發者。證書的所有者與主機名“10.150.0.2”不匹配
某些客戶端(例如wget)支持忽略 SSL 證書驗證。對于wget,請參閱--no-check-certificate標志。
一旦你解決了這個問題,你就會遇到另一組問題:
通常情況下,您不能將 HTTPS 與隧道一起使用。隧道是中間人的一種形式。有一些技巧可以使用,但沒有一個是安全的。
商業 SSL 證書不支持 IP 地址,只支持公共域名。您需要創建自己的自簽名證書,該證書不受信任或不會驗證證書。
最后一個問題是 HTTPS 端點需要來自客戶端的加密協商。在啟動IAP-隧道命令不會啟動加密(TLS協議)。此命令也不執行任何形式的證書交換,這就是您看不到有關證書的 IAP 錯誤的原因。此命令僅在隧道端點之間傳輸資料。
總而言之,如果不部署違背 HTTPS 目的的技巧和/或禁用功能,您就不能將 HTTPS 與 TCP / SSH 隧道一起使用。
uj5u.com熱心網友回復:
允許 IAP 流量通過防火墻允許我的外部客戶端通過 IAP 隧道連接到內部埠 943。
允許來自 35.235.240.0/20 的埠 943 解決了我的問題。
GCP IAP 檔案中提供了更多資訊
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/401305.html
