Lompat ke konten Lompat ke sidebar Lompat ke footer

Belajar Membuat SSL Self Sign Certificate di Centos 7

 Belajar Membuat SSL Self Sign Certificate di Centos 7

Pada kesempatan kali ini kita akan belajar membuat SSL Self Sign Certificate di Centos 7. Artikel ini adalah lanjutan dari Artikel sebelumnya yaitu Cara Install Apache Web Server di Centos 7. Buat kalian yang belum install Apache Web Server silahkan lihat pada Artikel tersebut.

SSL atau Secure Socket Layer adalah teknologi yang digunakan untuk mengamankan proses transmisi data dari server ke browser yang berlangsung di dalam sebuah website. Jika sebelumnya kita mengakses sebuah Website menggunakan protokol HTTP maka dengan menggunakan SSL kita dapat menggunakan HTTPS, dengan menggunakan SSL website lebih secure.

Self Sign Certificate merupakan sertifikat yang dibuat sendiri dan kemudian menyetujuinya (signed) sendiri juga. Self Signed Certificate bermanfaat misalnya untuk keperluan internal atau proses development website yang kedepannya akan menggunakan SSL.

Pada tutorial kali ini kita akan belajar bagaimana cara Install dan konfigurasi SSL Certificate di Centos 7 server menggunakan webserver Apache. Oke langsung saja ikuti step by step cara installasinya.  

Install OpenSSL

Silahkan jalankan perintah dibawah ini untuk Install paket module ssl dan openssl.

[root@centos ~]# yum install -y mod_ssl openssl
Kemudian masuk pada direktori /etc/pki/tls/certs/ lalu buat sertifikat dengan nama server.key
[root@centos ~]# cd /etc/pki/tls/certs/
[root@centos certs]# openssl genrsa -aes128 > server.key
Generating RSA private key, 2048 bit long modulus
...................+++
....+++
e is 65537 (0x10001)
Enter pass phrase:[Masukan Password]
Verifying - Enter pass phrase:[Masukan Password]
Kemudian hapus passphrase dari private.key    
[root@centos certs]# openssl rsa -in server.key -out server.key
Enter pass phrase for server.key:
writing RSA key
Selanjutnya buat CSR sertifikat
[root@centos certs]# openssl req -utf8 -new -key server.key -out 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]:IN
State or Province Name (full name) []:Jawa Barat
Locality Name (eg, city) [Default City]:Jakarta
Organization Name (eg, company) [Default Company Ltd]:PT.Contoh
Organizational Unit Name (eg, section) []:IT
Common Name (eg, your name or your server's hostname) []:contoh.com
Email Address []:admin@contoh.com

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []: [ENTER]
An optional company name []: [ENTER]
Kemudian atur waktu valid dari certificate
[root@centos certs]# openssl x509 -in server.csr -out server.crt -req -signkey server.key -days 3650
Signature ok
subject=/C=IN/ST=Jawa Barat/L=Jakarta/O=PT.Contoh/OU=IT/CN=contoh.com/emailAddress=admin@contoh.com
Getting Private key
Ganti permission file lalu Copy file server.key ke direktori /etc/pki/tls/private/
[root@centos certs]# chmod 600 server.key
[root@centos certs]# cp server.key /etc/pki/tls/private/
Selanjutnya edit file ssl.conf yang berada pada direktori /etc/httpd/conf.d/ edit pada bagian SSLCertificateFile dan SSLCertificateKeyFile arahkan pada direktori penyimpanan Sertifikat yang kita buat sebelumnya seperti dibawah ini.
[root@centos certs]# nano /etc/httpd/conf.d/ssl.conf

#   Server Certificate:
# Point SSLCertificateFile at a PEM encoded certificate.  If
# the certificate is encrypted, then you will be prompted for a
# pass phrase.  Note that a kill -HUP will prompt again.  A new
# certificate can be generated using the genkey(1) command.
SSLCertificateFile /etc/pki/tls/certs/server.crt

#   Server Private Key:
#   If the key is not combined with the certificate, use this
#   directive to point at the key file.  Keep in mind that if
#   you've both a RSA and a DSA private key you can configure
#   both in parallel (to also allow the use of DSA ciphers, etc.)
SSLCertificateKeyFile /etc/pki/tls/private/server.key
Langkah selanjutnya edit virtualhost yang sebelumnya kita buat lalu edit file tersebut seperti dibawah ini.
[root@centos certs]# nano /etc/httpd/conf.d/contoh.conf 

<VirtualHost *:443>
        SSLEngine on
        SSLCertificateFile /etc/pki/tls/certs/server.crt
        SSLCertificateKeyFile /etc/pki/tls/private/server.key
        DocumentRoot /var/www/html/website1
        ServerName www.contoh.com
        ServerAlias contoh.com
        ServerAdmin root@contoh.com
        ErrorLog logs/virtual.host_log
        CustomLog logs/virtual.host-access_log combined
</VirtualHost>
Simpan konfigurasi lalu restart service httpd
[root@centos certs]# systemctl restart httpd
Jangan lupa untuk menambahkan service https pada Firewalld
[root@centos ~]# firewall-cmd --add-service=https --permanent
success
[root@centos ~]# firewall-cmd --reload
success

Pengetesan

Setelah kita selesai mengkonfigurasi SSL Certificate saatnya kita akan melakukan pengetesan. Untuk pengetesan silahkan akses website Anda menggunakan browser pada PC Client lalu masukan pada url menggunakan https://www.domainanda.com jika muncul peringatan pada browser abaikan saja kemudian Klik Advanced lalu Klik pada bagian Accept the Risk and Continue.

Belajar Membuat SSL Self Sign Certificate di Centos 7

Hasilnya website dapat menggunakan protokol HTTPS.

Belajar Membuat SSL Self Sign Certificate di Centos 7

Demikian kira-kira tutorial Belajar Membuat SSL Self Sign Certificate di Centos 7 Server ini saya buat. Semoga bermafaat untuk kita semua. Silahkan Share Jika Kalian merasa postingan ini bermanfaat. Sekian & Terimakasih Salam.

1 komentar untuk "Belajar Membuat SSL Self Sign Certificate di Centos 7"

  1. Terima kasih pak materinya, saya sedang belajar konfigurasi linux server menggunakan centos dan terbantu dengan adanya artikel ini. Terima kasih pak.

    BalasHapus