Настройка ssl-аутентификации автономного сервера Wamp - PullRequest
0 голосов
/ 25 августа 2018

Хотите настроить переносной сервер из Apache, PHP и MySQL, все они из новейшего двоичного файла.

Скачали и настроили друг друга, но у них есть 2 проблемы, которые, я думаю, только одна.Во-первых: я установил уровень логирования в Info в httpd.conf и запустил сервер.Error.log содержит:

[Sat Aug 25 17:32:35.246609 2018] [ssl:info] [pid 13736:tid 592] AH01887: Init: Initializing (virtual) servers for SSL
[Sat Aug 25 17:32:35.246609 2018] [ssl:info] [pid 13736:tid 592] AH01914: Configuring server servertwo.tld:443 for SSL protocol
[Sat Aug 25 17:32:35.247609 2018] [ssl:info] [pid 13736:tid 592] AH02568: Certificate and private key servertwo.tld:443:0 configured from C:/wamp_p/Apache_2.4.34/conf/ssl/servertwo.crt and C:/wamp_p/Apache_2.4.34/conf/ssl/servertwo.key
[Sat Aug 25 17:32:35.247609 2018] [ssl:info] [pid 13736:tid 592] AH01914: Configuring server serverone.tld:443 for SSL protocol
[Sat Aug 25 17:32:35.247609 2018] [ssl:info] [pid 13736:tid 592] AH02568: Certificate and private key serverone.tld:443:0 configured from C:/wamp_p/Apache_2.4.34/conf/ssl/serverone.crt and C:/wamp_p/Apache_2.4.34/conf/ssl/serverone.key
[Sat Aug 25 17:32:35.249606 2018] [ssl:info] [pid 13736:tid 592] AH01914: Configuring server localhost:443 for SSL protocol
[Sat Aug 25 17:32:35.250605 2018] [ssl:warn] [pid 13736:tid 592] AH01909: localhost:443:0 server certificate does NOT include an ID which matches the server name
[Sat Aug 25 17:32:35.250605 2018] [ssl:info] [pid 13736:tid 592] AH02568: Certificate and private key localhost:443:0 configured from C:/wamp_p/Apache_2.4.34/conf/ssl/server.crt and C:/wamp_p/Apache_2.4.34/conf/ssl/server.key
[Sat Aug 25 17:32:35.250605 2018] [ssl:info] [pid 13736:tid 592] AH01876: mod_ssl/2.4.34 compiled against Server: Apache/2.4.34, Library: OpenSSL/1.1.0h
[Sat Aug 25 17:32:35.284684 2018] [socache_shmcb:info] [pid 13736:tid 592] AH00830: Shared memory socache initialised
[Sat Aug 25 17:32:35.284684 2018] [ssl:info] [pid 13736:tid 592] AH01887: Init: Initializing (virtual) servers for SSL
[Sat Aug 25 17:32:35.284684 2018] [ssl:info] [pid 13736:tid 592] AH01914: Configuring server servertwo.tld:443 for SSL protocol
[Sat Aug 25 17:32:35.285683 2018] [ssl:info] [pid 13736:tid 592] AH02568: Certificate and private key servertwo.tld:443:0 configured from C:/wamp_p/Apache_2.4.34/conf/ssl/servertwo.crt and C:/wamp_p/Apache_2.4.34/conf/ssl/servertwo.key
[Sat Aug 25 17:32:35.285683 2018] [ssl:info] [pid 13736:tid 592] AH01914: Configuring server serverone.tld:443 for SSL protocol
[Sat Aug 25 17:32:35.285683 2018] [ssl:info] [pid 13736:tid 592] AH02568: Certificate and private key serverone.tld:443:0 configured from C:/wamp_p/Apache_2.4.34/conf/ssl/serverone.crt and C:/wamp_p/Apache_2.4.34/conf/ssl/serverone.key
[Sat Aug 25 17:32:35.286682 2018] [ssl:info] [pid 13736:tid 592] AH01914: Configuring server localhost:443 for SSL protocol
[Sat Aug 25 17:32:35.286682 2018] [ssl:warn] [pid 13736:tid 592] AH01909: localhost:443:0 server certificate does NOT include an ID which matches the server name
[Sat Aug 25 17:32:35.286682 2018] [ssl:info] [pid 13736:tid 592] AH02568: Certificate and private key localhost:443:0 configured from C:/wamp_p/Apache_2.4.34/conf/ssl/server.crt and C:/wamp_p/Apache_2.4.34/conf/ssl/server.key
[Sat Aug 25 17:32:35.286682 2018] [ssl:info] [pid 13736:tid 592] AH01876: mod_ssl/2.4.34 compiled against Server: Apache/2.4.34, Library: OpenSSL/1.1.0h
[Sat Aug 25 17:32:35.297671 2018] [mpm_winnt:notice] [pid 13736:tid 592] AH00455: Apache/2.4.34 (Win64) OpenSSL/1.1.0h PHP/7.2.9 configured -- resuming normal operations
[Sat Aug 25 17:32:35.297671 2018] [mpm_winnt:notice] [pid 13736:tid 592] AH00456: Server built: Jul 10 2018 10:15:24
[Sat Aug 25 17:32:35.297671 2018] [mpm_winnt:info] [pid 13736:tid 592] AH80000: Distributed by: The Apache Haus
[Sat Aug 25 17:32:35.297671 2018] [mpm_winnt:info] [pid 13736:tid 592] AH80001: Compiled with: Visual Studio 2015
[Sat Aug 25 17:32:35.297671 2018] [core:notice] [pid 13736:tid 592] AH00094: Command line: 'Apache_2.4.34/bin/httpd.exe -d C:/wamp_p/Apache_2.4.34'
[Sat Aug 25 17:32:35.300667 2018] [mpm_winnt:notice] [pid 13736:tid 592] AH00418: Parent: Created child process 14088
[Sat Aug 25 17:32:35.660294 2018] [ssl:info] [pid 14088:tid 652] AH01887: Init: Initializing (virtual) servers for SSL
[Sat Aug 25 17:32:35.660294 2018] [ssl:info] [pid 14088:tid 652] AH01914: Configuring server servertwo.tld:443 for SSL protocol
[Sat Aug 25 17:32:35.661293 2018] [ssl:info] [pid 14088:tid 652] AH02568: Certificate and private key servertwo.tld:443:0 configured from C:/wamp_p/Apache_2.4.34/conf/ssl/servertwo.crt and C:/wamp_p/Apache_2.4.34/conf/ssl/servertwo.key
[Sat Aug 25 17:32:35.661293 2018] [ssl:info] [pid 14088:tid 652] AH01914: Configuring server serverone.tld:443 for SSL protocol
[Sat Aug 25 17:32:35.661293 2018] [ssl:info] [pid 14088:tid 652] AH02568: Certificate and private key serverone.tld:443:0 configured from C:/wamp_p/Apache_2.4.34/conf/ssl/serverone.crt and C:/wamp_p/Apache_2.4.34/conf/ssl/serverone.key
[Sat Aug 25 17:32:35.662292 2018] [ssl:info] [pid 14088:tid 652] AH01914: Configuring server localhost:443 for SSL protocol
[Sat Aug 25 17:32:35.662292 2018] [ssl:warn] [pid 14088:tid 652] AH01909: localhost:443:0 server certificate does NOT include an ID which matches the server name
[Sat Aug 25 17:32:35.662292 2018] [ssl:info] [pid 14088:tid 652] AH02568: Certificate and private key localhost:443:0 configured from C:/wamp_p/Apache_2.4.34/conf/ssl/server.crt and C:/wamp_p/Apache_2.4.34/conf/ssl/server.key
[Sat Aug 25 17:32:35.662292 2018] [ssl:info] [pid 14088:tid 652] AH01876: mod_ssl/2.4.34 compiled against Server: Apache/2.4.34, Library: OpenSSL/1.1.0h
[Sat Aug 25 17:32:35.688265 2018] [socache_shmcb:info] [pid 14088:tid 652] AH00830: Shared memory socache initialised
[Sat Aug 25 17:32:35.688265 2018] [ssl:info] [pid 14088:tid 652] AH01887: Init: Initializing (virtual) servers for SSL
[Sat Aug 25 17:32:35.688265 2018] [ssl:info] [pid 14088:tid 652] AH01914: Configuring server servertwo.tld:443 for SSL protocol
[Sat Aug 25 17:32:35.688265 2018] [ssl:info] [pid 14088:tid 652] AH02568: Certificate and private key servertwo.tld:443:0 configured from C:/wamp_p/Apache_2.4.34/conf/ssl/servertwo.crt and C:/wamp_p/Apache_2.4.34/conf/ssl/servertwo.key
[Sat Aug 25 17:32:35.688265 2018] [ssl:info] [pid 14088:tid 652] AH01914: Configuring server serverone.tld:443 for SSL protocol
[Sat Aug 25 17:32:35.689264 2018] [ssl:info] [pid 14088:tid 652] AH02568: Certificate and private key serverone.tld:443:0 configured from C:/wamp_p/Apache_2.4.34/conf/ssl/serverone.crt and C:/wamp_p/Apache_2.4.34/conf/ssl/serverone.key
[Sat Aug 25 17:32:35.689264 2018] [ssl:info] [pid 14088:tid 652] AH01914: Configuring server localhost:443 for SSL protocol
[Sat Aug 25 17:32:35.689264 2018] [ssl:warn] [pid 14088:tid 652] AH01909: localhost:443:0 server certificate does NOT include an ID which matches the server name
[Sat Aug 25 17:32:35.689264 2018] [ssl:info] [pid 14088:tid 652] AH02568: Certificate and private key localhost:443:0 configured from C:/wamp_p/Apache_2.4.34/conf/ssl/server.crt and C:/wamp_p/Apache_2.4.34/conf/ssl/server.key
[Sat Aug 25 17:32:35.689264 2018] [ssl:info] [pid 14088:tid 652] AH01876: mod_ssl/2.4.34 compiled against Server: Apache/2.4.34, Library: OpenSSL/1.1.0h
[Sat Aug 25 17:32:35.703250 2018] [mpm_winnt:notice] [pid 14088:tid 652] AH00354: Child: Starting 64 worker threads.

[ssl: warn] [pid 14088: tid 652] AH01909: localhost: 443: 0 сертификат сервера НЕ содержит идентификатор, соответствующий имени сервера *В строке 1007 * указано, что с сертификатом что-то не так.

httpd.conf содержит следующие соответствующие строки:

LoadModule ssl_module modules/mod_ssl.so
<IfModule ssl_module>
#Include conf/extra/httpd-ssl.conf
Include conf/extra/httpd-ahssl.conf
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin
</IfModule>

Файл ahssl.conf существует, и связанный сертификат также существует в

C:\wamp_p\Apache_2.4.34\conf\ssl\server.crt
C:\wamp_p\Apache_2.4.34\conf\ssl\server.key

Файл httpd-ahssl.conf является оригинальным, без изменений.

Выходные данные, относящиеся к PHPinfo, здесь

Когда я устанавливаю Apache каксистемная служба, она не запускается из-за этой ошибки, но я могу запустить ее вручную или командой net start, и она работает.

Второе: я установил phpmyadmin, но не настроил сервер (не скопировал ini),Когда я пытаюсь войти с тестовой учетной записью, это не может войти.Ошибка может быть замечена здесь

Когда я открываю cmd и регистрируюсь с помощью mysql -u test -p , это работает, и я также могу войти с помощью phpmyadmin,До тех пор, пока sql-сервер и / или http-сервер, не перезапущенный в любое время, не смогут войти в систему с тем пользователем, который также вошел в консоль в этом сеансе.

Это принадлежит ssl?

Я прокомментировал это на php.ini и httpd.conf, серверы были перезапущены, но проблема с входом в систему осталась прежней.

Что мне нужно сделать?Спасибо!

Обновление 1:

Я пытался создать новые сертификаты, но у меня возникли проблемы.Он не может найти файл конфигурации, но он там, где он ищет его.Двойная проверка:

c:\wamp_p\Apache_2.4.34\bin>openssl req -new -x509 -nodes -out server.crt -keyout server.key
Can't open 'C:\wamp_p\Apache_2.4.34\conf\openssl.cnf' for reading, Invalid argument
1664:error:0200107B:system library:fopen:Unknown error:crypto\bio\bss_file.c:74:fopen(''C:\wamp_p\Apache_2.4.34\conf\openssl.cnf'','rb')
1664:error:2006D002:BIO routines:BIO_new_file:system lib:crypto\bio\bss_file.c:83:
1664:error:0E078002:configuration file routines:def_load:system lib:crypto\conf\conf_def.c:152:
1664:error:0200107B:system library:fopen:Unknown error:crypto\bio\bss_file.c:74:fopen(''C:\wamp_p\Apache_2.4.34\conf\openssl.cnf'','r')
1664:error:2006D002:BIO routines:BIO_new_file:system lib:crypto\bio\bss_file.c:83:
Generating a 2048 bit RSA private key
......+++
..........................................................+++
writing new private key to 'server.key'
-----
unable to find 'distinguished_name' in config
problems making Certificate Request
1664:error:0E06D06A:configuration file routines:NCONF_get_string:no conf or environment variable:crypto\conf\conf_lib.c:272:

Я установил установку xampp и взял из нее файлы server.key и server.crt, не скопировал ее в мой каталог apache conf / ssl, а исходные файлы были перезаписаны.

Нет SSL: после этого была обнаружена предупреждающая запись в файле error.log после запуска сервера.

PhpMyAdmin по-прежнему не может войти в систему, пока я не войду с помощью mysql.exe с тестовым пользователем.Я не понимаю, какова связь между терминалом Windows и веб-браузером phpmyadmin.

Когда я успешно вошел в систему с помощью phpmyadmin, сделал снимок и увидел, что ssl не используется ...

Обновление 2:

Не думаю, что это проблема с сертификатом ssl.Это пошаговый тестовый код в консоли и веб-браузере:

----------------- Windows command line ----------------- 
c:\wamp_p\mysql_8.0.12\bin>net stop mysql
The MySQL service is stopping.
The MySQL service was stopped successfully.

----------------- Chrome browser with sqltest.php ----------------- 
Warning: mysqli_connect(): (HY000/2002): No connection could be made because the target machine actively refused it. in C:\wamp_p\htdocs\sql.php on line 3
Error: Unable to connect to MySQL. Debugging errno: 2002 Debugging error: No connection could be made because the target machine actively refused it.

----------------- Windows command line ----------------- 
c:\wamp_p\mysql_8.0.12\bin>net start mysql
The MySQL service is starting.
The MySQL service was started successfully.

----------------- Chrome browser with sqltest.php ----------------- 
Warning: mysqli_connect(): PHP was built without openssl extension, can't send password encrypted in C:\wamp_p\htdocs\sql.php on line 3
Warning: mysqli_connect(): (HY000/1045): Access denied for user 'test'@'localhost' (using password: YES) in C:\wamp_p\htdocs\sql.php on line 3
Error: Unable to connect to MySQL. Debugging errno: 1045 Debugging error: Access denied for user 'test'@'localhost' (using password: YES)

----------------- Windows command line ----------------- 
c:\wamp_p\mysql_8.0.12\bin>mysql -u test -p
Enter password: ****
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.12 MySQL Community Server - GPL

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

----------------- Chrome browser with sqltest.php ----------------- 
Warning: mysqli_connect(): (HY000/1049): Unknown database 'my_db' in C:\wamp_p\htdocs\sql.php on line 3
Error: Unable to connect to MySQL. Debugging errno: 1049 Debugging error: Unknown database 'my_db'

----------------- Windows command line ----------------- 
mysql> quit
Bye

c:\wamp_p\mysql_8.0.12\bin>

----------------- Chrome browser with sqltest.php ----------------- 
Warning: mysqli_connect(): (HY000/1049): Unknown database 'my_db' in C:\wamp_p\htdocs\sql.php on line 3
Error: Unable to connect to MySQL. Debugging errno: 1049 Debugging error: Unknown database 'my_db'

Обновление 3:

Сервер Mysql 8 меняет метод аутентификации , поэтому принудительный откат к старому плагину пароля решает проблему входа в систему.Выполните установку на сервер MySQL для my.ini со следующим содержимым:

[mysqld]
default_authentication_plugin=mysql_native_password

1 Ответ

0 голосов
/ 29 августа 2018

К первой части:

Openssh.exe найден в каталоге bin Apache.

Имя сервера найдено в apache / conf / extra / httpd-ahssl.confфайл в директиве виртуального сервера.В моем случае это localhost.

Openssh.cnf находится в каталоге apache conf.

Создайте файлы ключей и CRT, скопируйте их в conf / ssl dir и перезапустите сервер.

openssl req -new -newkey rsa:2048 -sha256 -days 365 -nodes -x509 -keyout server.key -out server.crt -config "C:\wamp_p\Apache_2.4.34\conf\openssl.cnf"

Во вторую часть (для phpmyadmin):

MySQL Server 8 имеет новый плагин аутентификации пароля по умолчанию.Чтобы применить плагин с оригинальным паролем, создайте my.ini в корневом каталоге mysql.

[mysqld]
default_authentication_plugin=mysql_native_password

Если вы уже создали пользователей, вам нужно изменить его.Вы можете проверить плагин аутентификации по паролю для пользователя с помощью

USE MYSQL;
SELECT user,host,plugin from user;

Пока!

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...