Kenapa curl tidak berfungsi pada suatu website

Salah satu pelanggan Jasa Linux SysAdmin mengalami permasalahan dengan sertifikat SSL [HTTPS]. Websitenya sih normal saja ketika diakses memakai web browser, HTTPS berjalan dengan baik. Tapi ketika diakses menggunakan tool cURL, maka muncullah errornya dan gagal melakukan koneksi ke web server.

cURL [client URL] adalah tool yang berfungsi untuk melakukan transfer data melalui URL. cURL umumnya terdapat di sistem operasi Linux/Unix-like.

cURL atau library cURL biasanya digunakan untuk mengakses RESTful web service.

Kembali ke permasalahan, ketika menjalankan perintah curl ke website, tampil pesan error curl: [60] SSL certificate problem: unable to get local issuer certificate.

curl -I //domain.com curl: [60] SSL certificate problem: unable to get local issuer certificate More details here: //curl.haxx.se/docs/sslcerts.html curl failed to verify the legitimacy of the server and therefore could not establish a secure connection to it. To learn more about this situation and how to fix it, please visit the web page mentioned above.

curl -I https://domain.com

curl: [60] SSL certificate problem: unable to get local issuer certificate

More details here: https://curl.haxx.se/docs/sslcerts.html

curl failed to verify the legitimacy of the server and therefore could not

establish a secure connection to it. To learn more about this situation and

how to fix it, please visit the web page mentioned above.

curl: [60] SSL certificate problem

Pesan error di atas menjelaskan bahwa curl tidak mengenali pihak yang menerbitkan sertifikat SSL yang terpasang di domain tersebut.

Gagal memverifikasi keabsahan server maka tidak bisa melanjutkan koneksi ke server demi alasan keamanan.

Solusi CURL SSL Error

Solusi masalah di atas adalah menggabungkan file .crt dengan file ca-bundle melalui perintah cat.

cat domain_com.crt domain_com.ca-bundle > domain_com.ssl

cat domain_com.crt domain_com.ca-bundle > domain_com.ssl

File yang dihasilkan dari proses penggabungan di atas kemudian dimasukkan ke konfigurasi web server sebagai file sertifikat SSL.

Contoh konfigurasi SSL pada Nginx web server.

ssl on; ssl_certificate /etc/ssl/domain_com.ssl; ssl_certificate_key /etc/ssl/domain_com.key;

ssl_certificate /etc/ssl/domain_com.ssl;

ssl_certificate_key /etc/ssl/domain_com.key;

Restart web server lalu coba uji kembali mengakses website dengan curl.

curl -I //domain.com HTTP/2 200 server: nginx/1.16.1 date: Sat, 09 Nov 2019 09:48:12 GMT content-type: text/html; charset=UTF-8 vary: Accept-Encoding x-powered-by: PHP/7.1.33 last-modified: Sat, 09 Nov 2019 09:17:52 GMT

curl -I https://domain.com

date: Sat, 09 Nov 2019 09:48:12 GMT

content-type: text/html; charset=UTF-8

last-modified: Sat, 09 Nov 2019 09:17:52 GMT

curl berhasil mengakses website

Selamat mencoba 🙂

Video yang berhubungan

Bài Viết Liên Quan

Bài mới nhất

Chủ Đề