CentOS 또는 EC2 apache에서 SSL 자체 인증서 발급 (https)
줄거리
선배에게 가르쳐 준 서버 구축 비망록, SSL을 발행해 443포트에서 볼 수 있도록 한다.
OpenSSL
암호화 키의 작성에 사용하는 라이브러리입니다.
mod_ssl
Apache httpd 에서 HTTPS 로의 접속을 실현하기 위해서 사용하는 모듈입니다.
설치
인스톨 해 갑시다, 이후의 터미널의 기술은 root 유저가 아니면 머리에 sudo 를 붙이자
$ yum -y install mod_ssl
#インストールが完了すると /etc/httpd/conf.d/ssl.conf に mod_ssl の設定ファイルが作成されます。
#(CentOSのみ)
$ yum -y install openssl
개인 키 및 SSL 인증서 작성
ec2의 경우 작성 위치는 ~입니다. 진짜는 격납처에서 만들고 싶었습니다만, sudo로 해도 안 되었으므로 나중에 mv로 이사합니다.
먼저 server.key라는 개인 키가 포함된 파일을 만듭니다.
[ec2-user@ip ~]$ openssl genrsa 2024 > server.key
Generating RSA private key, 2024 bit long modulus
............................+++
...............................................................................+++
그런 다음 인증서 서명 요청을 만듭니다.
인증서 서명 요청은 인증 기관이 서버의 공개 키에 전자 서명하도록 요청하는 메시지입니다.
[ec2-user@ip ~]$ openssl req -new -key server.key > server.csr
You are about to be asked to enter information that will be incorporated
into 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 blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [XX]:JP
State or Province Name (full name) []:Tokyo
Locality Name (eg, city) [Default City]:Oota-ku
Organization Name (eg, company) [Default Company Ltd]:test
Organizational Unit Name (eg, section) []:
Common Name (eg, your name or your server's hostname) []test.net
Email Address []:
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:
이제 server.csr이라는 파일이 생성되었습니다.
서버 인증서 만들기
마지막으로이 문서의 아티팩트 인 서버 인증서를 만듭니다.
보통이라면 위에서 작성한 증명서 서명 요구(server.csr)를 VeriSign등의 기관에 송부해 인증국의 비밀열쇠로 서명해 주겠습니다만, 이번은 스스로 서명하는 것으로 서버 증명서 를 작성하므로, 위에서 작성한 자신의 비밀열쇠(server.key)로 서명합니다.
[ec2-user@ip ~]$ openssl x509 -req -days 3650 -signkey server.key < server.csr > server.crt
Signature ok
subject=/C=JP/ST=Tokyo/L=Oota-ku/O=test/CN=test.net
Getting Private key
이제 세 개의 파일을 만들었습니다.
[ec2-user@ip ~]$ ls
server.crt server.csr server.key
다음으로 OpenSSL로 만들어지는 파일의 저장처를 만들어 이동시킵니다.
[ec2-user@ip ~]$ mkdir /etc/httpd/conf/ssl
[ec2-user@ip ~]$ mv server.crt /etc/httpd/conf/ssl
[ec2-user@ip ~]$ mv server.csr /etc/httpd/conf/ssl
[ec2-user@ip ~]$ mv server.key /etc/httpd/conf/ssl
[ec2-user@ip ~]$ ls /etc/httpd/conf/ssl
server.crt server.csr server.key
다음으로 mod_ssl 설정 파일을 편집합시다.
[ec2-user@ip ~]$ cd /etc/httpd/conf.d/
#設定ファイルのバックアップ(.orgを付けてファイル複製)
[ec2-user@ip conf.d]$ cp ssl.conf ssl.conf.org
[ec2-user@ip conf.d]$ vim ssl.conf
#100行目にあるSSLCertificateFileを修正
SSLCertificateFile /etc/httpd/conf/ssl/server.crt
#107行目にあるSSLCertificateKeyFileを修正
SSLCertificateKeyFile /etc/httpd/conf/ssl/server.key
#保存したら再起動
[ec2-user@ip conf.d]$ sudo systemctl restart httpd
재기동이 잘 되면 https(443번 포트)로 넣게 되었을 것입니다. URL을 https://로 바꾸어 들어 봅시다! 작동하지 않으면 포트가 해제되었는지 확인하십시오.

이렇게 변하면 성공입니다! 개인으로 만든 증명서이므로 이런 표시가 되는 것이군요.
상세 버튼을 눌러 액세스를 선택하여 http 때와 변하지 않는 것이 표시되면 OK입니다!
이제 https를 사용할 수 있습니다! 다음은 리버스 프록시라고 하는 것을 도입해 보자고 생각합니다. 그럼 또.
참고문헌
OpenSSL에서 SSL 자체 인증서를 발급하는 단계
Reference
이 문제에 관하여(CentOS 또는 EC2 apache에서 SSL 자체 인증서 발급 (https)), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/PAmatsuti/items/a38eba94650af37382b9
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
$ yum -y install mod_ssl
#インストールが完了すると /etc/httpd/conf.d/ssl.conf に mod_ssl の設定ファイルが作成されます。
#(CentOSのみ)
$ yum -y install openssl
[ec2-user@ip ~]$ openssl genrsa 2024 > server.key
Generating RSA private key, 2024 bit long modulus
............................+++
...............................................................................+++
[ec2-user@ip ~]$ openssl req -new -key server.key > server.csr
You are about to be asked to enter information that will be incorporated
into 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 blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [XX]:JP
State or Province Name (full name) []:Tokyo
Locality Name (eg, city) [Default City]:Oota-ku
Organization Name (eg, company) [Default Company Ltd]:test
Organizational Unit Name (eg, section) []:
Common Name (eg, your name or your server's hostname) []test.net
Email Address []:
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:
[ec2-user@ip ~]$ openssl x509 -req -days 3650 -signkey server.key < server.csr > server.crt
Signature ok
subject=/C=JP/ST=Tokyo/L=Oota-ku/O=test/CN=test.net
Getting Private key
[ec2-user@ip ~]$ ls
server.crt server.csr server.key
[ec2-user@ip ~]$ mkdir /etc/httpd/conf/ssl
[ec2-user@ip ~]$ mv server.crt /etc/httpd/conf/ssl
[ec2-user@ip ~]$ mv server.csr /etc/httpd/conf/ssl
[ec2-user@ip ~]$ mv server.key /etc/httpd/conf/ssl
[ec2-user@ip ~]$ ls /etc/httpd/conf/ssl
server.crt server.csr server.key
[ec2-user@ip ~]$ cd /etc/httpd/conf.d/
#設定ファイルのバックアップ(.orgを付けてファイル複製)
[ec2-user@ip conf.d]$ cp ssl.conf ssl.conf.org
[ec2-user@ip conf.d]$ vim ssl.conf
#100行目にあるSSLCertificateFileを修正
SSLCertificateFile /etc/httpd/conf/ssl/server.crt
#107行目にあるSSLCertificateKeyFileを修正
SSLCertificateKeyFile /etc/httpd/conf/ssl/server.key
#保存したら再起動
[ec2-user@ip conf.d]$ sudo systemctl restart httpd
Reference
이 문제에 관하여(CentOS 또는 EC2 apache에서 SSL 자체 인증서 발급 (https)), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/PAmatsuti/items/a38eba94650af37382b9텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)