search

New

6/recent/ticker-posts

How to Enable ssl or https for localhost on Macos

 I use Xampp Server on Mac-OS then I meet the problem with https://localhost like the message:



Secure Connection Failed An error occurred during a connection to localhost. SSL received a record that exceeded the maximum permissible length. Error code: SSL_ERROR_RX_RECORD_TOO_LONG The page you are trying to view cannot be shown because the authenticity of the received data could not be verified. Please contact the website owners to inform them of this problem.

* There are the solution:

- Step 1: Open /Applications/XAMPP/xamppfiles/etc/httpd.conf and make sure your settings are the same as below:

Add two lines

LoadModule socache_shmcb_module lib/httpd/modules/mod_socache_shmcb.so
LoadModule socache_dbm_module modules/mod_socache_dbm.so

<IfModule ssl_module>

<IfDefine SSL>

Include etc/extra/httpd-ssl.conf

</IfDefine>

</IfModule>

- Step 2: config with this command:

sudo /Applications/XAMPP/xamppfiles/xampp enablessl

- Step 3: Edit httpd-ssl.conf

  • Open /Applications/XAMPP/xamppfiles/etc/extra/httpd-ssl.conf
  • Change default port from 8443 to 443

#Listen 8443

Listen 443

  • Find this line and remove everything below it

## SSL Virtual Host Context

Open Terminal

-Step 4 : Create SSL folder to store SSL files

cd

/Applications/XAMPP/xamppfiles/etc/

mkdir ssl

cd ssl

-Step 5 : Create SSL CSR & private key

You can use any file name here (just replace localhost)

openssl req -new -newkey rsa:2048 -nodes -keyout localhost.key -out localhost.csr

Enter info as below. Note: change localhost to your localhost domain name (ex: www.domain.name)

Country Name (2 letter code) [AU]:PN

State or Province Name (full name) [Some-State]:Phnom Penh

Locality Name (eg, city) []:Applaor

Organization Name (eg, company) [Internet Widgits Pty Ltd]:Applaor

Organizational Unit Name (eg, section) []:IT

Common Name (e.g. server FQDN or YOUR name) []:localhost

Email Address []:applaor@gmail.com

Leave these info BLANK (just Enter, no need input anything)

-Step 6 : Create .ext file

touch localhost.ext

Copy & paste below content to v3.ext file

Note: change localhost to your localhost domain name

authorityKeyIdentifier=keyid,issuer

basicConstraints=CA:FALSE

keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment

subjectAltName = @alt_names

[alt_names]

DNS.1 = localhost

-Step 7 : Create SSL CRT

openssl x509 -req -sha256 -extfile localhost.ext -days 3650 -in localhost.csr -signkey localhost.key -out localhost.crt

8. Add SSL CRT to macOS Keychain

  • Double click on localhost.crt on Finder
  • Select Keychain: System then click Add

XAMPP - Setup HTTPS/SSL localhost on macOS

  • Find & double click on localhost cert in Keychain Access
  • Expand Trust, select When using this certificates: Always Trust

XAMPP - Setup HTTPS/SSL localhost on macOS

  • Close the window and click Update Settings

9. Config SSL in XAMPP virtual host

Open /Applications/XAMPP/xamppfiles/etc/extra/httpd-ssl.conf

Update your config:

from

<VirtualHost *:80>

ServerName localhost

DocumentRoot "/Applications/XAMPP/xamppfiles/htdocs"

</VirtualHost>

to

<VirtualHost *:443>

ServerName localhost

DocumentRoot "/Applications/XAMPP/xamppfiles/htdocs"

SSLEngine on

SSLCertificateFile "/Applications/XAMPP/xamppfiles/etc/ssl/localhost.crt"

SSLCertificateKeyFile "/Applications/XAMPP/xamppfiles/etc/ssl/localhost.key"

</VirtualHost>


 


 

 

Post a Comment

0 Comments

Contact Form

Name

Email *

Message *

Random Products

Learning English