Author Topic: generate certificate for https website on freebsd , centos , debian  (Read 33947 times)

golfreeze

  • Administrator
  • Hero Member
  • *****
  • Posts: 2140
    • View Profile
    • นั่งสมาธิ สติปัฏฐานสี่ พาเที่ยววัด แนะนำวัด แจกcd ธรรมะฟรี
    • Email
Re: generate certificate for https website on freebsd , centos , debian
« Reply #15 on: มีนาคม 21, 2017, 06:37:38 PM »
วิธีการ import certificate from Window OS (certname.pfx) into Apache ssl key file (key.pem)
#openssl pkcs12 -in certname.pfx -nocerts -out key.pem -nodes

วิธีการ import certificate from Window OS (certname.pfx) into Apache ssl Cert file (cert.pem)
#openssl pkcs12 -in certname.pfx -nokeys -out cert.pem

วิธีการ export certificate จาก .crt (apache) -> .pfx ผ่าน openssl
How do I export, as a pfx file, my Certificate and Private Key from Apache?
In order to export the Certificate, Private Key and any intermediate certificate as a pfx file use the command below:
#openssl pkcs12 -export -in my.crt -inkey my.key -certfile my.bundle -out my.pfx
« Last Edit: พฤศจิกายน 12, 2017, 07:42:16 AM by golfreeze »

golfreeze

  • Administrator
  • Hero Member
  • *****
  • Posts: 2140
    • View Profile
    • นั่งสมาธิ สติปัฏฐานสี่ พาเที่ยววัด แนะนำวัด แจกcd ธรรมะฟรี
    • Email
Re: generate certificate for https website on freebsd , centos , debian
« Reply #16 on: มีนาคม 21, 2017, 06:38:07 PM »
Check a certificate

Check a certificate and return information about it(Signing authority, expiration date, etc.)

openssl x509 -in server.crt -text -noout
Check a key

Check the SSL key and verify the consistency.

openssl rsa -in server.key -check
Check a CSR

Verify the CSR and print CSR data filled in when generating the CSR.

openssl req -text -noout -verify -in server.csr
Verify a certificate and key matches

The following two commands will print out md5 sums of the certificate and key. These sums can be compared to verify that the certificate and key match.

openssl x509 -noout -modulus -in server.crt| openssl md5
openssl rsa -noout -modulus -in server.key| openssl md5

golfreeze

  • Administrator
  • Hero Member
  • *****
  • Posts: 2140
    • View Profile
    • นั่งสมาธิ สติปัฏฐานสี่ พาเที่ยววัด แนะนำวัด แจกcd ธรรมะฟรี
    • Email
Re: generate certificate for https website on freebsd , centos , debian
« Reply #17 on: มีนาคม 26, 2017, 09:36:32 AM »
ปกติแล้วถ้าตอนเราทำการเช็คความถูกต้องของการใส่ Chain cert ใน configure ของ WebServer
ในกรณีนี้ผมยกตัวอย่าง Apache + Mod_SSL นะครับ
หลังจากเราทำการใส่ Chain cert ลงไปแล้ว หลังจากนั้นทำการตรวจสอบแล้วพบว่า
ตรวจสอบกับ https://www.ssllabs.com/ssltest/

Chain issues : Incorrect order, Contains anchor
->เกิดมาจากการจัดลำดับของ CA-bundle สลับกันถึงขึ้นเป็น Incorrect order
->เกิดจากการผสมเอา CARoot กับ CA-bundle รวมในไฟล์เดียวกันถึงแสดงเป็น Contains anchor

แก้ไขโดยให้ทำการตรวจสอบ configure ในไฟล์คอนฟิค ssl.conf หรือ default-ssl.conf ว่าถูกต้องหรือเปล่า เช่น

#ควรใช้ไฟล์ที่ทาง CA ส่งมาเป็นไฟล์ ca-bundle.crt มาใส่ในส่วนนี้ แล้วลองทำการจัดเรียงลำดับให้ถูกต้องครับ
SSLCertificateChainFile /opt/ssl/ca-bundle.ca

#ควรใช้ไฟล์ที่ทาง CA ส่งมาให้เช่นไฟล์ AddTrustExternalCARoot.ca ใส่ในส่วนนี้
SSLCACertificateFile /opt/ssl/CARoot.ca

หลังจากนั้นทำการตรวจสอบกับ SSLLab อีกรอบ ก็จะทำให้แก้ไขปัญหา Incorrect order และ Contains anchor ได้ครับ  ;)

ทีมงาน Packetlove.com
เราให้บริการ Certificate SSL พร้อมการคอนฟิคและให้คำปรึกษาการใช้งาน SSL ครับ

golfreeze

  • Administrator
  • Hero Member
  • *****
  • Posts: 2140
    • View Profile
    • นั่งสมาธิ สติปัฏฐานสี่ พาเที่ยววัด แนะนำวัด แจกcd ธรรมะฟรี
    • Email
Re: generate certificate for https website on freebsd , centos , debian
« Reply #18 on: มิถุนายน 16, 2017, 08:31:34 PM »
ถ้าในกรณี มีการเช็คสถานะของ SSL บนเว็บนั้นๆ แล้วเจอ DH ที่เป็น CipherSuite เตือนว่ามีความเสี่ยงไม่ปลอดภัย
สามารถแก้ไขด้วยการ อัฟเกรด apache version จาก 2.2.x -> 2.4.x ได้ครับ
###ถ้าใน directadmin ก็เริ่มโดย
cd /usr/local/DirectAdmin/custombuild
./build set apache_ver 2.4
./build update
./build clean
./build apache n
./build php n
service httpd restart

##Increasing DHE strength on Apache 2.4.x

Apache HTTP Server (mod_ssl)

SSL parameters can globally be set in httpd.conf or within specific virtual hosts.

SSLCipherSuite          ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA

SSLHonorCipherOrder     on
DH Parameters

In newer versions of Apache (2.4.8 and newer) and OpenSSL 1.0.2 or later, you can directly specify your DH params file as follows:

SSLOpenSSLConfCmd DHParameters "{path to dhparams.pem}"
If you are using Apache with LibreSSL, or Apache 2.4.7 and OpenSSL 0.9.8a or later, you can append the DHparams you generated earlier to the end of your certificate file.

Reload configuration

sudo service apache2 reload

golfreeze

  • Administrator
  • Hero Member
  • *****
  • Posts: 2140
    • View Profile
    • นั่งสมาธิ สติปัฏฐานสี่ พาเที่ยววัด แนะนำวัด แจกcd ธรรมะฟรี
    • Email
Re: generate certificate for https website on freebsd , centos , debian
« Reply #19 on: พฤศจิกายน 12, 2017, 09:20:57 AM »
Convert your SSL Certificate to the Correct File Type

Different servers require different formats of SSL certificates. Our SSL converter tool converts between 6 different file formats quickly and easily. Choose the file format which is required: PEM, DER, PKCS#7, P7B, PKCS#12 or PFX.

DER format

Is a binary form of PEM. It has extension .der or .cer.

DER is typically used with Java platforms. Our Converter can change the type of certificate to this format - to change a private key, please use OpenSSL commands.

PKCS#7 or P7B format

Is usually stored in Base64 format and has extension .p7b or .p7c. Files in this format contain lines "-----BEGIN PKCS7-----" and "-----END PKCS7-----". This format is just for certificates, not for private keys.

PKCS#7 and P7B are installed on Microsoft Windows and Java Tomcat servers.

PKCS#12 or PFX format

Is a binary format storing the server certificate, intermediates certificates, and private key in one file. It usually has the extension .pfx or .p12. Typically, these are used on Windows machines.

When converting PFX format to PEM, one file will include all certificates and the private key.

To separate it, you need to open this file in a simple text editor, copy every single part (with BEGIN and END lines) to different files and save it as certificate.cer, CACert.cer and privatekey.key.

golfreeze

  • Administrator
  • Hero Member
  • *****
  • Posts: 2140
    • View Profile
    • นั่งสมาธิ สติปัฏฐานสี่ พาเที่ยววัด แนะนำวัด แจกcd ธรรมะฟรี
    • Email
Re: generate certificate for https website on freebsd , centos , debian
« Reply #20 on: พฤศจิกายน 12, 2017, 10:01:28 AM »
การใช้งาน Comodo กับ IIS8

วิธีการ convert จาก .crt -> .cer เพื่อนำไปใช้กับ IIS 8 (บน Window Server)
https://support.comodo.com/index.php?/Knowledgebase/Article/View/361/17/how-do-i-convert-crt-file-into-the-microsoft-cer-format

และตามด้วยการ import ลงไปยัง IIS 8
https://support.comodo.com/index.php?/Knowledgebase/Article/View/1159/37/certificate-installation-microsoft-iis-8x

ถ้าเราทำการ generate .csr จาก openssl แล้วทำการขอ .crt จาก CA ที่ Trust แล้ว
มีโจทย์ว่าต้องการนำ .crt ที่ได้มานั้น ไป import เป็น .pfx เพื่อใช้กับ Window server หรือ IIS 8.x ขึ้นไป จะมีวิธีการดังนี้
1.แปลงจาก p7b เพื่อทำการ import ใน mmc ของ Window server
2.แล้วทำรันการ  certutil เพื่อ repairstore
3.สุดท้ายค่อย export ออกมาเป็น .pfx ลงใน IIS 8.x Server
#certutil -repairstore my "PLACE_SERIAL_NUMBER_HERE"
https://www.ssl.com/how-to/fix-the-iis-7-no-private-key-error-message/
« Last Edit: พฤศจิกายน 13, 2017, 10:44:50 AM by golfreeze »

golfreeze

  • Administrator
  • Hero Member
  • *****
  • Posts: 2140
    • View Profile
    • นั่งสมาธิ สติปัฏฐานสี่ พาเที่ยววัด แนะนำวัด แจกcd ธรรมะฟรี
    • Email
Re: generate certificate for https website on freebsd , centos , debian
« Reply #21 on: มีนาคม 25, 2018, 09:35:12 PM »
การใช้งาน certbot + letencrypt บน centos6.x on Apache

##Reference link
https://certbot.eff.org/all-instructions/
https://certbot.eff.org/lets-encrypt/centos6-apache

เริ่มกันเลย โดยสามารถทำการ download และติดตั้ง python-certbot-apache
wget https://dl.eff.org/certbot-auto
chmod a+x certbot-auto
ทำการสร้าง ssl
./certbot-auto --apache certonly
« Last Edit: มีนาคม 25, 2018, 09:42:19 PM by golfreeze »

golfreeze

  • Administrator
  • Hero Member
  • *****
  • Posts: 2140
    • View Profile
    • นั่งสมาธิ สติปัฏฐานสี่ พาเที่ยววัด แนะนำวัด แจกcd ธรรมะฟรี
    • Email
Re: generate certificate for https website on freebsd , centos , debian
« Reply #22 on: กันยายน 22, 2018, 10:57:10 AM »
In case Cert let encrypt expired , way to renew cert from let encrypt
#gitlab-ctl reconfigure

after that try to access your gitlab url again
https://www.packetlove.com
then check ssl valid date.

golfreeze

  • Administrator
  • Hero Member
  • *****
  • Posts: 2140
    • View Profile
    • นั่งสมาธิ สติปัฏฐานสี่ พาเที่ยววัด แนะนำวัด แจกcd ธรรมะฟรี
    • Email
Re: generate certificate for https website on freebsd , centos , debian
« Reply #23 on: พฤศจิกายน 10, 2018, 11:33:43 AM »
ในกรณีถ้าเจอ RSA PRIVATE KEY กับ header แบบนี้ แสดงว่ามี รหัสของ encrypted key ครับ
If you have an RSA PRIVATE KEY with headers that look something like:
-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: DES-EDE3-CBC,D061ACF7F7A7D27F
then you would have a password encrypted key.

ให้ทำการ decrypted key โดย command openssl
openssl rsa -in /path/to/your/key -out /the/new/key

แล้วทำการ ปรับ configure ใน ssl.conf ใหม่อีกทีนะครับ
คราวนี้เวลา restart web server ก็ไม่ต้องใส่ passparse แล้ว