Установить SSL с CA для нескольких локальных сайтов в Apache и пройти аутентификацию в определенном месте (код ошибки: ssl_error_handshake_failure_alert) Ubuntu

Я пытаюсь реализовать SSL (HTTP) на моем локальном веб-сервере для защиты указанных каталогов на веб-сайтах Apache, где пользователь входит в систему, сочетая SSL и HTTP Authentication Basic. Здесь я следую инструкциям и в основном apache mod_ssl. Я настроил локальный CA и создал сертификат CA "cacert.pem":

sudo openssl req -new -x509 -extensions v3_ca -keyout /etc/ssl/CA/private/cakey.pem -out /etc/ssl/CA/cacert.pem -days 3650
sudo openssl ca -gencrl -out /etc/ssl/CA/crl/crl.pem

Созданные ключи и сертификаты:

sudo openssl genrsa -out webserver.key 2048
sudo openssl req -new -key webserver.key -out webserver.csr
sudo openssl ca -in webserver.csr -config /etc/ssl/openssl.cnf
# and now we have generated sighted certifivate "webserver.pem"
sudo openssl genrsa -out website.key 2048
sudo openssl req -new -key website.key -out website.csr
sudo openssl ca -in website.csr -config /etc/ssl/openssl.cnf
# and now we have generated sighted certifivate "website.crt"
sudo openssl pkcs12 -export -clcerts -in website.crt -inkey website.key -out website.p12

Я включил mod_ssl и отредактировал строки в default-ssl:

<IfModule mod_ssl.c>
<VirtualHost _default_:443>
    SSLEngine on
    SSLCertificateFile    /path/to/apache/webserver.pem
    SSLCertificateKeyFile /path/to/apache/webserver.key
    SSLCACertificatePath /etc/ssl/CA/certs/
    SSLCACertificateFile /etc/ssl/CA/cacert.pem
    SSLCARevocationPath /etc/ssl/CA/crl/
    SSLCARevocationFile /etc/ssl/CA/crl/crl.pem
</VirtualHost>
</IfModule>

Мой локальный website.conf (внутри сайтов с поддержкой) выглядит так:

<VirtualHost *:80>
    ServerAdmin admin@website.com
    ServerName local.website.com
    DocumentRoot /path/to/public_html
    ErrorLog /path/to/error_log
    CustomLog /path/to/access_log combined
    DirectoryIndex index.php index.html
    <Directory /path/to/public_html>
        Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
    </Directory>
</VirtualHost>
<IfModule mod_ssl.c>
    <VirtualHost *:443>
        ServerAdmin admin@gwebsite.com
        ServerName local.website.com
        DocumentRoot /path/to/public_html

        SSLEngine on
        SSLVerifyClient      none
        SSLCertificateFile /path/to/website.crt
        SSLCertificateKeyFile /path/to/website.key

        <Location /secure_area >
            SSLRequireSSL
        </Location>

    </VirtualHost>
</IfModule>

Мои.htacces внутри папки, которые мне нужны для защиты, выглядят так:

### Redirecting ###
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{SERVER_PORT} !^443$
    RewriteCond %{REQUEST_URI} ^/secure_area(/)?$
    RewriteRule ^(.*) https://%{SERVER_NAME}%{REQUEST_URI} [R,L]
</IfModule>

### HTTP Authentication ###
<IfModule mod_authn_file.c>
    AuthType Basic
#   SSLRequireSSL
#   SSLVerifyClient      require    
    SSLVerifyDepth       3
    SSLCipherSuite       RC4-SHA:AES128-SHA:HIGH:!aNULL:!MD5
    SSLOptions           +FakeBasicAuth     
    AuthName "Restricted Area."
    AuthUserFile /path/to/htpasswd
    <Limit GET POST>
        Require valid-user
    </Limit>
    Satisfy All
</IfModule>

Работа в порядке, но если я раскомментирую "SSLVerifyClient", мой браузер вернет сообщение "Код ошибки: ssl_error_handshake_failure_alert". Также, если я раскомментирую "SSLRequireSSL"(и удаляю его из моего website.conf), он будет перенаправлен на мою страницу с ошибкой. Что я делаю неправильно? Я что-то здесь упускаю? Где, кажется, проблема? сертификаты, apache или что-то еще?

0 ответов

Другие вопросы по тегам