प्रौद्योगिकी साझेदारी

[RHCE] उपयोक्तृप्रमाणीकरणस्य TLS एन्क्रिप्शनस्य च आधारेण HTTP सेवा (HTTPS)

2024-07-12

한어Русский языкEnglishFrançaisIndonesianSanskrit日本語DeutschPortuguêsΕλληνικάespañolItalianoSuomalainenLatina

सामग्रीसूची

1. उपयोक्तृलेखं रचयन्तु

2. TLS एन्क्रिप्शन

3. http service sub-configuration file विन्यस्यताम्

4. http सेवां प्राप्तुं एकं पुटं रचयन्तु तथा च निवेशं सञ्चिकायां पुनः निर्दिशन्तु

5. Windows इत्यस्य अधः Linux स्थानीयगोदामस्य स्थानीयगोदामस्य च विन्यस्तं कुर्वन्तु

6. मूलभूतक्रियाः

7. परीक्षणम्


1. उपयोक्तृलेखं रचयन्तु

उपयोक्तृप्रमाणीकरणम्

  1. # 创建两个账户
  2. [root@localhost ~]# htpasswd -c /etc/httpd/zhanghao tom
  3. New password:
  4. Re-type new password:
  5. Adding password for user tom
  6. [root@localhost ~]# htpasswd /etc/httpd/zhanghao jerry
  7. New password:
  8. Re-type new password:
  9. Adding password for user jerry
  10. # 查看是否创建成功
  11. [root@localhost ~]# tail /etc/httpd/zhanghao
  12. tom:$apr1$2s/wloz6$G0SlGTKB62a4.2gJmy.AL.
  13. jerry:$apr1$lOxB9Dtq$tOTaJ35Jtt8dWouHbjgWi1

2. TLS एन्क्रिप्शन

1. mod_ssl डाउनलोड् कुर्वन्तु

[root@localhost ~]# yum install mod_ssl -y

नोटः- सॉफ्टवेयरं डाउनलोड् कर्तुं भवद्भिः गोदामं विन्यस्तं कृत्वा माउण्ट् करणीयम् यदि आवश्यकं भवति तर्हि मया पूर्वं लिखितं लेखं पश्यितुं शक्यते ।

2.tls एन्क्रिप्शन: 1.1.

  1. # 创建密钥
  2. [root@localhost certs]# openssl genrsa -aes128 2048 > jiami.key
  3. # 输入密码
  4. Enter PEM pass phrase:
  5. Verifying - Enter PEM pass phrase:
  6. # 创建证书
  7. [root@localhost certs]# openssl req -utf8 -new -key jiami.key -x509 -days 100 -out jiami.crt
  8. Enter pass phrase for jiami.key:
  9. You are about to be asked to enter information that will be incorporated
  10. into your certificate request.
  11. What you are about to enter is what is called a Distinguished Name or a DN.
  12. There are quite a few fields but you can leave some blank
  13. For some fields there will be a default value,
  14. If you enter '.', the field will be left blank.
  15. -----
  16. Country Name (2 letter code) [XX]:86 # 国家
  17. State or Province Name (full name) []:shaanxi # 省份
  18. Locality Name (eg, city) [Default City]:xi'an # 城市
  19. Organization Name (eg, company) [Default Company Ltd]:rhce # 组织
  20. Organizational Unit Name (eg, section) []:peihua # 组织单元
  21. Common Name (eg, your name or your server's hostname) []:www.hehe.com # 主机名!!!
  22. Email Address []:[email protected] # 邮箱

3.मोबाइल कुञ्जी स्थानं

  1. # 移动密钥位置
  2. [root@localhost certs]# cd /etc/pki/tls/certs
  3. # 密钥位置为/etc/pki/tls/private/jiami.key
  4. [root@localhost certs]# mv jiami.key ../private/

4. /etc/httpd/conf.d/ssl.conf सञ्चिकां परिवर्तयन्तु

  1. SSLCertificateFile /etc/pki/tls/certs/jiami.crt
  2. SSLCertificateKeyFile /etc/pki/tls/private/jiami.key

भवता स्वस्य कृते निर्मिताः कीलानि प्रमाणपत्राणि च परिवर्तयन्तु

3. http service sub-configuration file विन्यस्यताम्

  1. [root@localhost certs]# vim /etc/httpd/conf.d/vhost.conf
  2. # 重启服务时需要输入创建tls时的密码
  3. [root@localhost certs]# systemctl restart httpd
  4. 🔐 Enter TLS private key passphrase for www.hehe.com:443 (RSA) : ******

दस्तावेज सामग्रीः १.

  1. <directory /www>
  2. allowoverride none
  3. require all granted
  4. </directory>
  5. # 用户认证
  6. <directory /usr/local/secret>
  7. authtype basic
  8. authname "Please input your passwd: "
  9. authuserfile /etc/httpd/zhanghao
  10. require user tom jerry
  11. </directory>
  12. # tls加密,地址为自己的主机地址,端口为443代表https服务
  13. <virtualhost 192.168.198.151:443>
  14. SSLEngine on
  15. SSLCertificateFile /etc/pki/tls/certs/jiami.crt
  16. SSLCertificateKeyFile /etc/pki/tls/private/jiami.key
  17. documentroot /www/hehe
  18. servername www.hehe.com
  19. alias /hehe /usr/local/secret
  20. </virtualhost>

http सेवा पुनः आरभत

systemctl restart httpd

4. http सेवां प्राप्तुं एकं पुटं रचयन्तु तथा च निवेशं सञ्चिकायां पुनः निर्दिशन्तु

  1. [root@localhost certs]# mkdir /www
  2. [root@localhost certs]# mkdir /www/hehe
  3. [root@localhost certs]# mkdir /usr/local/secret
  4. [root@localhost certs]# echo hehe > /www/hehe/index.html
  5. [root@localhost certs]# echo secret > /usr/local/secret/index.html

5. Windows इत्यस्य अधः Linux स्थानीयगोदामस्य स्थानीयगोदामस्य च विन्यस्तं कुर्वन्तु

1.Linux स्थानीय गोदाम (/आदि/मेजबान)

  1. [root@localhost certs]# vim /etc/hosts
  2. 192.168.198.151 www.hehe.com

2. विण्डोज मध्ये स्थानीयभण्डारं विन्यस्यताम्

यदि भवन्तः ब्राउजरे परीक्षणं कर्तुं प्रवृत्ताः सन्ति तर्हि Windows स्थानीयभण्डारं (C:WindowsSystem32driversetchosts) विन्यस्तुं आवश्यकम् ।

२.१ win+r धावन्तं विण्डो उद्घाटयितुं

२.२ctrl+shift+enter, प्रशासकरूपेण चालयन्तु

2.3 "notepad" इति प्रविष्टं कुर्वन्तु ततः Notepad pop up भविष्यति ।

२.४ सञ्चिकां उद्घाटयन्तु

2.5 /windows/system32/drivers/etc/hosts इति चिन्वन्तु

2.6 hosts सञ्चिकायां कोडं योजयन्तु

192.168.198.151  www.hehe.com

6. मूलभूतक्रियाः

  1. [root@localhost certs]# systemctl stop firewalld
  2. [root@localhost certs]# setenforce 0
  3. # 修改过子配置文件,都需要重启http服务,生效
  4. [root@localhost certs]# systemctl restart httpd

7. परीक्षणम्