الرئيسية في VPSie

العودة إلى قاعدة المعرفة

مقدمة عن Openssl

Openssl هو مجموعة من مكتبات C وأدوات مكتوبة بلغة C لأنظمة التشغيل Linux و*BSD وSolaris وAIX وWindows (وغيرها)، ينفذ بروتوكولات SSL وTLS، ويوفر وظائف وأدوات تشفير لإدارة PKI. تتطلب مهام مسؤول VPS Linux اليومية التعامل مع OpenSSL لتوليد الشهادات والتحقق منها واستكشاف أخطاء SSL/TLS ومواقع HTTPS.

شهادات SSL – المفهوم

كما يوحي الاسم، شهادات Openssl هي شهادات رقمية تتيح لطرفين، عادةً خادم ويب HTTPS وعميل (متصفح) أو طرفي IPSEC، المصادقة المتبادلة وتشفير وتوقيع البيانات المتبادلة. HTTPS هو آلية تشفير بروتوكول HTTP النص الصريح باستخدام SSL أو TLS، وهو آمن (نظرياً)، ومن هنا جاء حرف S. يُصمم HTTPS ليكون آمناً لأنه يستخدم زوجاً من المفتاح الخاص والمفتاح العام، حيث يُرمز كل منهما في شهادة منفصلة: الشهادة الخاصة (يُشار إليها عادةً بالمفتاح) والشهادة العامة (يُشار إليها عادةً بشهادة CRT أو PEM). PEM هو في الواقع آلية ترميز لشهادات SSL.

SSL public certificates can be self signed (they are their own issuer) or they can be signed by a recognized Certificate Authority (CA) – free or commercially. In the case of the vast majority of HTTPS website, they obtain the public / private key pair (an SSL private certificate/key actually holds a public public [modulus] key and a private [exponent] key) via internally generated mechanisms such as Openssl or via 3rd party security devices. From the private part, OpenSSL will extract the public key (modulus) and create a Certificate Signing Request (CSR). The CSR is sent to a public or private Certificate Authority to sign the CSR that results in a public certificate. The public certificate Subject and Issure sections, after it has been signed, will look like:


    Signature Algorithm: sha256WithRSAEncryption
        Issuer: C=IL, O=StartCom Ltd., OU=Secure Digital Certificate Signing, CN=StartCom Class 1 Primary Intermediate Server CA
        Validity
            Not Before: Feb  5 02:45:55 2015 GMT
            Not After : Feb  5 15:43:21 2016 GMT
        Subject: C=NL, CN=www.domain.com/[email protected]

يخبر هذا المتصفح بأن الشهادة التي يستلمها من موقع HTTPS صالحة ل www.domain.com، وهي صالحة بين 5 فبراير 2015 و5 فبراير 2016، وقد وقّعها Issuer الذي يثق به المتصفح مسبقاً. وبالتالي، لن يعرض المتصفح تحذيراً عند وصوله إلى الموقع على https://www.domain.com خلال الفترة الزمنية التي تكون فيها الشهادة صالحة.

The security of HTTPS websites is founded on the basic principle (and more complex SSL handshake) that the public certificate provided by an HTTPS server to its clients is signed by a 3rd party – the Certificate Authority – that is trusted by these clients, as in the example above.

استخدام Openssl لتوليد شهادات لخادم الويب الخاص بك على VPS بنظام Linux

بصفته عميل VPSie، عند نشر خادم VPS بنظام Linux، وبعد تخصيص VPS وتأمينه بما يتوافق مع متطلباتك، حان الوقت لنشر حزم Linux التي تتيح تحويل خادم VPS الخاص بك إلى خادم خدمات.

إذا كان نطاق VPS هو استضافة موقع ويب عبر HTTPS، فستحتاج إلى زوج المفاتيح الخاصة/العامة (المفتاح الخاص) وطلب توقيع الشهادة (CSR).

توليد شهادات OpenSSL SSL

جميع حزم Linux VPS لدينا مجهزة ب OpenSSL افتراضيًا، لذا لا توجد متطلبات مسبقة مباشرة لتوليد المفتاح الخاص ل SSL وطلب توقيع الشهادة (CSR).

حول Openssl genrsa
يمكنك استخدام مجلد /etc/ssl/ لتخزين شهاداتك. وحدة openssl المسؤولة عن توليد المفتاح الخاص RSA هي genrsa.
يمكن تشفير المفتاح الخاص باستخدام خوارزميات DES/3DES/AES/Camelia أو تركه غير مشفر. إذا اخترت تشفيره، فسيكون مطلوبًا إدخال كلمة مرور.

root@vpsie:~# cd /etc/ssl/private/
root@vpsie:/etc/ssl/private# openssl genrsa -h
usage: genrsa [args] [numbits]
 -des            encrypt the generated key with DES in cbc mode
 -des3           encrypt the generated key with DES in ede cbc mode (168 bit key)
 -seed
                 encrypt PEM output with cbc seed
 -aes128, -aes192, -aes256
                 encrypt PEM output with cbc aes
 -camellia128, -camellia192, -camellia256
                 encrypt PEM output with cbc camellia
 -out file       output the key to 'file
 -passout arg    output file pass phrase source
 -f4             use F4 (0x10001) for the E value
 -3              use 3 for the E value
 -engine e       use engine e, possibly a hardware device.
 -rand file:file:...
                 load the file (or the files in the directory) into
                 the random number generator

توليد مفتاح خاص مشفر / شهادة

root@vpsie:/etc/ssl/private# openssl genrsa -aes128 -out private.key 2048
Generating RSA private key, 2048 bit long modulus
..................................................+++
...................................................+++
e is 65537 (0x10001)
Enter pass phrase for private.key:
Verifying - Enter pass phrase for private.key:

الآن وبعد حصولنا على المفتاح الخاص، الخطوة التالية هي توليد طلب توقيع شهادة يجب إرساله إلى سلطة الشهادات للتوقيع عليه:


root@vpsie:/etc/ssl/private# openssl req -new -key private.key -out certificate.csr
Enter pass phrase for private.key:
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) [AU]:US
State or Province Name (full name) [Some-State]:New York
Locality Name (eg, city) []:New York
Organization Name (eg, company) [Internet Widgits Pty Ltd]My Linux VPS
Organizational Unit Name (eg, section) []:VPS
Common Name (e.g. server FQDN or YOUR name) []:www.mydomain.com
Email Address []:[email protected]

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
root@vpsie:/etc/ssl/private# cat certificate.csr
-----BEGIN CERTIFICATE REQUEST-----
MIIC3jCCAcYCAQAwgZgxCzAJBgNVBAYTAlVTMREwDwYDVQQIDAhOZXcgWW9yazER
MA8GA1UEBwwITmV3IFlvcmsxFjAUBgNVBAoMDVZNeSBMaW51eCBWUFMxDDAKBgNV
BAsMA1ZQUzEZMBcGA1UEAwwQd3d3Lm15ZG9tYWluLmNvbTEiMCAGCSqGSIb3DQEJ
ARYTYW5kcmVpQG15ZG9tYWluLmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC
AQoCggEBALOjKtbuRemm88No93EfoGeVZU+7IGr6AIaqX0esKDxq5Vtlm+71gc2z
msRL6G7xJU4DvbBdOKBkSKaSdEhPt4uCtgHJpNSA1ez0s2FFXASbN3LPR9oxmyxl
W8oCmAkZNP9B+H0i9kpRs3FtVQzb3fWVMw9slB7bh2p1ZZg/PJm7fE2uAg7vcMAg
9FL+MNKKq7WDSafGqvCV+kVYmguAmgGbsfq2wB0X6I9v0i7sx0Fxmc+B8ZwDj1us
heq5Lt9kF4c63DEjfGhIG8wT8aCIgir7PdCHttppfJz4uXK092EI37ImwDl2lKsX
+Rg2ojqhXzKbxtX4mZoZS0dUlOhladcCAwEAAaAAMA0GCSqGSIb3DQEBBQUAA4IB
AQA/zOGxiGx8JW4SCnY99bsaiA4zr/a0g33A7E/tSx4gNP9C5CKUk3TUNrZL0h4h
dEwr5yNcp90UWo0zZ6TXid+XaaAcGaF63uX+GrE5lIBSmCX3BohHAaKlYIZG9Pr/
I0pSMfqU6dQQy4CbMiFy0hrBBgcdQIs1xeFVHtU8uG1nFAAsHM+7kaGIjD8yYiOo
4Hf+bEzN+PUEmOwRNsxs4tT4MpeR1U7BBRevtzh3sZ3pRNlJ2lPX/z2+P3rQUARc
9Fq92ORt5TrJHUnTO4tsYxBf8W5P9qckXbmMM9jkMfIDx5RQ0QaTxyaI1uO70Srg
gMZSPb8FRdqtgc1Xha/FIAhK
-----END CERTIFICATE REQUEST-----

في مقال قادم، سنناقش كيفية التسجيل للحصول على شهادة ssl مجانية من سلطة شهادات موثوقة.

يمكنك في الواقع تجربة إعدادات SSL هذه على منصتنا في دقائق معدودة باستخدام حلول السحابة الخاصة (PCS) لدينا، والتي تتيح لك امتلاك خوادم VPSie على شبكة خاصة – NAT – إعادة توجيه المنافذ – التحكم في حركة المرور الواردة والصادرة – عناوين IP متعددة للبوابات يمكنك استخدامها لتوزيع الأحمال والتعافي من الأعطال.

                    Try us free for one full month today! 

العودة إلى قاعدة المعرفة