openSSL not working with PHP built-in webserver

后端 未结 2 882
情歌与酒
情歌与酒 2020-12-08 01:35

OS: Ubuntu 12.04 64-bit

PHP version: 5.4.6-2~precise+1

When I test an https page I am writing through the built-in webserve

相关标签:
2条回答
  • 2020-12-08 01:48

    See the manual section on the built-in webserver shim:
    http://php.net/manual/en/features.commandline.webserver.php

    It doesn't support SSL encryption. It's for plain HTTP requests. The openssl extension and function support is unrelated. It does not accept requests or send responses over the stream wrappers.

    If you want SSL to run over it, try a stunnel wrapper:

    php -S localhost:8000 &   
    stunnel3 -d 443 -r 8080  
    

    It's just for toying anyway.

    0 讨论(0)
  • 2020-12-08 01:58

    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).

    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.

    In my case, I kept running into an issue where I declare HTTPS somewhere but php artisan serve only works on 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 Axios to make a POST request to https://. Changing it to POST http:// fixed it.

    My recommendation to anyone would be to take a look at where and how HTTP/HTTPS is being used.

    The textbook definition is probably something like php artisan serve only works over HTTP but requires underlying SSL layer.

    0 讨论(0)
提交回复
热议问题