Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Methods of creating and installing self-signed certificates in Apache

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Editor to share with you how to create and install self-signed certificates in Apache, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

SSL is useful for secure communication between users and Web servers. The certificate encrypts the data when it is transmitted on the public line so that it is not attacked by hackers. Self-signed certificates are used free of charge, but not in production environments, such as the use of confidential data such as credit cards and Paypal information. This article describes how to create and install self-signed certificates in an Apache server on a Linux system.

Step 1: install the mod_ssl package

To set up the SSL certificate, make sure that mod_ssl is installed on the system. If it is not already installed, you need to use the following command to install it. In addition, install the openssl package to create the certificate.

$sudo apt-get install openssl # Debian based systems $sudo yum install mod_ssl openssl # Redhat / CentOS systems $sudo dnf install mod_ssl openssl # Fedora 22 + systems

Step 2: create a self-signed certificate

After installing mod_ssl and openssl, use the following command to create a self-signed certificate for your domain.

$sudo mkdir-p / etc/pki/tls/certs$ sudo cd / etc/pki/tls/certs

Now create the SSL certificate

$sudo openssl req-x509-nodes-newkey rsa:2048-keyout example.com.key-out example.com.crt

Output

Generating a 2048 bit RSA private key..+++..+++writing new private key to 'example.com.key'-You are about to be asked to enter information that will be incorporatedinto your certificate request.What you are about to enter is What is called a Distinguished Name or a DN.There are quite a few fields but you can leave some blankFor some fields there will be a default value If you enter'.', the field will be left blank.-Country Name (2 letter code) [XX]: INState or Province Name (full name) []: DelhiLocality Name (eg, city) [Default City]: DelhiOrganization Name (eg, company) [Default Company Ltd]: TecAdminOrganizational Unit Name (eg, section) []: blogCommon Name (eg, your name or your server's hostname) []: www.example.comEmail Address []: admin@example.com

The above command creates a ssl key file example.com.key and a certificate file example.com.crt in the current directory.

Step 3: install a self-signed certificate in Apache

You now have a self-signed SSL certificate and key file. Next, edit the Apache SSL configuration file and follow the instructions below to edit / update.

Apache virtual host configuration:

ServerAdmin admin@example.com ServerName www.example.com ServerAlias example.com DocumentRoot / var/www/html SSLEngine on SSLCertificateFile / etc/pki/tls/certs/example.com.crt SSLCertificateKeyFile / etc/pki/tls/certs/example.com.key

Step 4: restart Apache

If the above command does not show any errors, restart the Apache service.

$sudo systemctl restart apache2 # Debian based systems $sudo systemctl restart httpd # Redhat based systems

Step 5: test the website using https

Finally, use https to open your site in your Web browser. It needs to open port 443 to access the site using HTTPS.

Https://www.example.com

When we use a self-signed certificate, you will receive a warning message in your browser. Just ignore it.

The above is all the contents of the method of creating and installing self-signed certificates in Apache. Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report