openSSL 不适用于 PHP 内置网络服务器
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12946486/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
openSSL not working with PHP built-in webserver
提问by user1755025
OS:Ubuntu 12.04 64-bit
操作系统:Ubuntu 12.04 64 位
PHP version:5.4.6-2~precise+1
PHP版本:5.4.6-2~精确+1
When I test an https page I am writing through the built-in webserver (php5 -S localhost:8000), Firefox (16.0.1) says "Problem loading: The connection was interrupted", while the terminal tells me "::1:37026 Invalid request (Unsupported SSL request)".
当我通过内置网络服务器 (php5 -S localhost:8000) 测试 https 页面时,Firefox (16.0.1) 显示“加载问题:连接中断”,而终端告诉我“::1 :37026 无效请求(不支持的 SSL 请求)”。
phpinfo()tells me:
phpinfo()告诉我:
- Registered Stream Socket Transports: tcp, udp, unix, udg, ssl, sslv3, tls
- [curl] SSL: Yes
- SSL Version: OpenSSL/1.0.1
openssl:
OpenSSL support: enabled
OpenSSL Library Version OpenSSL 1.0.1 14 Mar 2012
OpenSSL Header Version OpenSSL 1.0.1 14 Mar 2012
- 注册流套接字传输:tcp、udp、unix、udg、ssl、sslv3、tls
- [卷曲] SSL:是
- SSL 版本:OpenSSL/1.0.1
打开SSL:
OpenSSL 支持:已启用
OpenSSL 库版本 OpenSSL 1.0.1 2012 年 3 月 14 日
OpenSSL 标头版本 OpenSSL 1.0.1 2012 年 3 月 14 日
Yes, http pages work just fine.
是的,http 页面工作得很好。
Any ideas?
有任何想法吗?
回答by mario
See the manual section on the built-in webserver shim:
http://php.net/manual/en/features.commandline.webserver.php
请参阅内置网络服务器垫片的手册部分:http:
//php.net/manual/en/features.commandline.webserver.php
It doesn't support SSL encryption. It's for plain HTTP requests. The opensslextension and function support is unrelated. It does not accept requests or send responses over the stream wrappers.
它不支持 SSL 加密。它用于普通的 HTTP 请求。在openssl扩展和功能的支持是不相关的。它不接受请求或通过流包装器发送响应。
If you want SSL to run over it, try a stunnelwrapper:
如果您希望 SSL 在其上运行,请尝试使用stunnel包装器:
php -S localhost:8000 &
stunnel3 -d 443 -r 8080
It's just for toying anyway.
反正就是玩玩而已。
回答by agm1984
I've been learning nginx and Laravel recently, and this error has came up many times. It's hard to diagnose because you need to align nginx with Laravel and also the SSL settings in your operating system at the same time (assuming you are making a self-signed cert).
最近在学习nginx和Laravel,这个错误出现了很多次。很难诊断,因为您需要同时将 nginx 与 Laravel 以及操作系统中的 SSL 设置对齐(假设您正在制作自签名证书)。
If you are on Windows, it is even more difficult because you have to fight unix carriage returns when dealing with SSL certs. Sometimes you can go through the steps correctly, but you get ruined by cert validation issues. I find the trick is to make the certs in Ubuntu or Mac and email them to yourself, or use the linux subsystem.
如果您使用的是 Windows,则更加困难,因为您在处理 SSL 证书时必须与 unix 回车进行斗争。有时您可以正确地完成这些步骤,但您会被证书验证问题毁了。我发现诀窍是在 Ubuntu 或 Mac 中制作证书并将它们通过电子邮件发送给自己,或者使用 linux 子系统。
In my case, I kept running into an issue where I declare HTTPSsomewhere but php artisan serveonly works on HTTP.
就我而言,我一直遇到一个问题,我在某处声明了HTTPS但php artisan serve仅适用于HTTP。
I just caused this Invalid request (Unsupported SSL request)error again after SSL was hooked up fine. It turned out to be that I was using Axiosto make a POST request to https://. Changing it to POST http://fixed it.
Invalid request (Unsupported SSL request)在 SSL 连接好后,我再次导致了这个错误。原来是我Axios用来向https://. 将其更改为 POSThttp://修复了它。
My recommendation to anyone would be to take a look at where and howHTTP/HTTPS is being used.
我对任何人的建议是查看HTTP/HTTPS 的使用位置和使用方式。
The textbook definition is probably something like php artisan serveonly works over HTTP but requires underlying SSL layer.
教科书定义可能类似于php artisan serve仅适用于 HTTP 但需要底层 SSL 层。

