自上次更新以来已经过去了三年。以下是我如何在2021年在macOS上使用它(作为马里奥答案的扩展):
# Install stunnel
brew install stunnel
# Find the configuration directory
cd /usr/local/etc/stunnel
# Copy the sample conf file to actual conf file
cp stunnel.conf-sample stunnel.conf
# Edit conf
vim stunnel.conf
修改,使其看起来像这样:(所有其他选项都可以删除)stunnel.conf
; **************************************************************************
; * Global options *
; **************************************************************************
; Debugging stuff (may be useful for troubleshooting)
; Enable foreground = yes to make stunnel work with Homebrew services
foreground = yes
debug = info
output = /usr/local/var/log/stunnel.log
; **************************************************************************
; * Service definitions (remove all services for inetd mode) *
; **************************************************************************
; ***************************************** Example TLS server mode services
; TLS front-end to a web server
[https]
accept = 443
connect = 8000
cert = /usr/local/etc/stunnel/stunnel.pem
; "TIMEOUTclose = 0" is a workaround for a design flaw in Microsoft SChannel
; Microsoft implementations do not use TLS close-notify alert and thus they
; are vulnerable to truncation attacks
;TIMEOUTclose = 0
这在端口 443 接受 HTTPS/SSL,并使用 stunnel 的默认伪造证书 (在 ) 连接到在端口 8000 上运行的本地 Web 服务器。日志级别为 ,并将日志输出写入 。/usr/local/etc/stunnel/stunnel.pem
info
/usr/local/var/log/stunnel.log
启动隧道:
brew services start stunnel # Different for Linux
启动网络服务器:
php -S localhost:8000
现在您可以访问以访问您的Web服务器:屏幕截图https://localhost:443
应该有一个证书错误,你必须点击浏览器警告,但这会让你达到你可以用HTTPS请求击中本地主机的地步,用于开发。