• Secure. • Compliant. • Trust at the Core. • Built for Saudi Arabia. by K® (Kenzie) SAUDI GULF HOSTiNG an Enterprise of Company Kanz AlKhaleej AlArabi, All rights Reserved.
Knowledgebase
Apache HTTP Server

SSL/TLS Strong Encryption: How-To

This document is intended to get you started, and get a few things working. You are strongly encouraged to read the rest of the SSL documentation, and arrive at a deeper understanding of the material, before progressing to the advanced techniques.

Basic Configuration Example

Your SSL configuration will need to contain, at minimum, the following directives.

LoadModule ssl_module modules/mod_ssl.so

Listen 443
<VirtualHost *:443>
    ServerName www.example.com
    SSLEngine on
    SSLCertificateFile "/path/to/www.example.com.cert"
    SSLCertificateKeyFile "/path/to/www.example.com.key"
</VirtualHost>

Cipher Suites and Enforcing Strong Security

How can I create an SSL server which accepts strong encryption only?

The following enables only the strongest ciphers:

SSLCipherSuite HIGH:!aNULL:!MD5

While with the following configuration you specify a preference for specific speed-optimized ciphers (which will be selected by mod_ssl, provided that they are supported by the client):

SSLCipherSuite RC4-SHA:AES128-SHA:HIGH:!aNULL:!MD5
SSLHonorCipherOrder on

How can I create an SSL server which accepts all types of ciphers in general, but requires a strong ciphers for access to a particular URL?

Obviously, a server-wide SSLCipherSuite which restricts ciphers to the strong variants, isn't the answer here. However, mod_ssl can be reconfigured within Location blocks, to give a per-directory solution, and can automatically force a renegotiation of the SSL parameters to meet the new configuration. This can be done as follows:

# be liberal in general
SSLCipherSuite ALL:!aNULL:RC4+RSA:+HIGH:+MEDIUM:+LOW:+EXP:+eNULL

<Location "/strong/area">
# but https://hostname/strong/area/ and below
# requires strong ciphers
SSLCipherSuite HIGH:!aNULL:!MD5
</Location>

OCSP Stapling

The Online Certificate Status Protocol (OCSP) is a mechanism for determining whether or not a server certificate has been revoked, and OCSP Stapling is a special form of this in which the server, such as httpd and mod_ssl, maintains current OCSP responses for its certificates and sends them to clients which communicate with the server. Most certificates contain the address of an OCSP responder maintained by the issuing Certificate Authority, and mod_ssl can communicate with that responder to obtain a signed response that can be sent to clients communicating with the server.

Because the client can obtain the certificate revocation status from the server, without requiring an extra connection from the client to the Certificate Authority, OCSP Stapling is the preferred way for the revocation status to be obtained. Other benefits of eliminating the communication between clients and the Certificate Authority are that the client browsing history is not exposed to the Certificate Authority and obtaining status is more reliable by not depending on potentially heavily loaded Certificate Authority servers.

Because the response obtained by the server can be reused for all clients using the same certificate during the time that the response is valid, the overhead for the server is minimal.

Once general SSL support has been configured properly, enabling OCSP Stapling generally requires only very minor modifications to the httpd configuration — the addition of these two directives:

SSLUseStapling On
SSLStaplingCache "shmcb:logs/ssl_stapling(32768)"

These directives are placed at global scope (i.e., not within a virtual host definition) wherever other global SSL configuration directives are placed, such as in conf/extra/httpd-ssl.conf for normal open source builds of httpd, /etc/apache2/mods-enabled/ssl.conf for the Ubuntu or Debian-bundled httpd, etc.

The path on the SSLStaplingCache directive (e.g., logs/) should match the one on the SSLSessionCache directive. This path is relative to ServerRoot.

This particular SSLStaplingCache directive requires mod_socache_shmcb (from the shmcb prefix on the directive's argument). This module is usually enabled already for SSLSessionCache or on behalf of some module other than mod_ssl. If you enabled an SSL session cache using a mechanism other than mod_socache_shmcb, use that alternative mechanism for SSLStaplingCache as well. For example:

SSLSessionCache "dbm:logs/ssl_scache"
SSLStaplingCache "dbm:logs/ssl_stapling"

You can use the openssl command-line program to verify that an OCSP response is sent by your server:

$ openssl s_client -connect www.example.com:443 -status -servername www.example.com
...
OCSP response: 
======================================
OCSP Response Data:
    OCSP Response Status: successful (0x0)
    Response Type: Basic OCSP Response
...
    Cert Status: Good
...

The following sections highlight the most common situations which require further modification to the configuration. Refer also to the mod_ssl reference manual.

If more than a few SSL certificates are used for the server

OCSP responses are stored in the SSL stapling cache. While the responses are typically a few hundred to a few thousand bytes in size, mod_ssl supports OCSP responses up to around 10K bytes in size. With more than a few certificates, the stapling cache size (32768 bytes in the example above) may need to be increased. Error message AH01929 will be logged in case of an error storing a response.

If the certificate does not point to an OCSP responder, or if a different address must be used

Refer to the SSLStaplingForceURL directive.

You can confirm that a server certificate points to an OCSP responder using the openssl command-line program, as follows:

$ openssl x509 -in ./www.example.com.crt -text | grep 'OCSP.*http'
OCSP - URI:http://ocsp.example.com

If the OCSP URI is provided and the web server can communicate to it directly without using a proxy, no configuration is required. Note that firewall rules that control outbound connections from the web server may need to be adjusted.

If no OCSP URI is provided, contact your Certificate Authority to determine if one is available; if so, configure it with SSLStaplingForceURL in the virtual host that uses the certificate.

If multiple SSL-enabled virtual hosts are configured and OCSP Stapling should be disabled for some

Add SSLUseStapling Off to the virtual hosts for which OCSP Stapling should be disabled.

If the OCSP responder is slow or unreliable

Several directives are available to handle timeouts and errors. Refer to the documentation for the SSLStaplingFakeTryLater, SSLStaplingResponderTimeout, and SSLStaplingReturnResponderErrors directives.

If mod_ssl logs error AH02217

AH02217: ssl_stapling_init_cert: Can't retrieve issuer certificate!

In order to support OCSP Stapling when a particular server certificate is used, the certificate chain for that certificate must be configured. If it was not configured as part of enabling SSL, the AH02217 error will be issued when stapling is enabled, and an OCSP response will not be provided for clients using the certificate.

Refer to the SSLCertificateChainFile and SSLCertificateFile for instructions for configuring the certificate chain.

Tuning OCSP Stapling for production

The default OCSP stapling settings are conservative and may result in excessive queries to OCSP responders, timeouts, or error responses being cached for too long. The following settings are recommended for production use:

# Do not pass OCSP responder errors to clients:
SSLStaplingReturnResponderErrors off

# Reduce the OCSP responder timeout from the default 10s:
SSLStaplingResponderTimeout 4

# Cache valid OCSP responses for 48 hours (default: 1 hour).
# This reduces load on OCSP responders and avoids transient
# errors caused by frequent queries:
SSLStaplingStandardCacheTimeout 172800

# Retry failed OCSP queries after 60 seconds instead of the
# default 600s:
SSLStaplingErrorCacheTimeout 60

These settings address common issues where default OCSP stapling produces errors under load — particularly when OCSP responders are slow or unreliable. See the individual directive documentation for SSLStaplingReturnResponderErrors, SSLStaplingResponderTimeout, SSLStaplingStandardCacheTimeout, and SSLStaplingErrorCacheTimeout for details.

Client Authentication and Access Control

How can I force clients to authenticate using certificates?

When you know all of your users (eg, as is often the case on a corporate Intranet), you can require plain certificate authentication. All you need to do is to create client certificates signed by your own CA certificate (ca.crt) and then verify the clients against this certificate.

# require a client certificate which has to be directly
# signed by our CA certificate in ca.crt
SSLVerifyClient require
SSLVerifyDepth 1
SSLCACertificateFile "conf/ssl.crt/ca.crt"

How can I force clients to authenticate using certificates for a particular URL, but still allow arbitrary clients to access the rest of the server?

To force clients to authenticate using certificates for a particular URL, you can use the per-directory reconfiguration features of mod_ssl:

SSLVerifyClient none
SSLCACertificateFile "conf/ssl.crt/ca.crt"

<Location "/secure/area">
SSLVerifyClient require
SSLVerifyDepth 1
</Location>

How can I allow only clients who have certificates to access a particular URL, but allow all clients to access the rest of the server?

The key to doing this is checking that part of the client certificate matches what you expect. Usually this means checking all or part of the Distinguished Name (DN), to see if it contains some known string. There are two ways to do this, using either mod_auth_basic or SSLRequire.

The mod_auth_basic method is generally required when the certificates are completely arbitrary, or when their DNs have no common fields (usually the organization, etc.). In this case, you should establish a password database containing all clients allowed, as follows:

SSLVerifyClient      none
SSLCACertificateFile "conf/ssl.crt/ca.crt"
SSLCACertificatePath "conf/ssl.crt"

<Directory "/usr/local/apache2/htdocs/secure/area">
    SSLVerifyClient      require
    SSLVerifyDepth       5
    SSLOptions           +FakeBasicAuth
    SSLRequireSSL
    AuthName             "Snake Oil Authentication"
    AuthType             Basic
    AuthBasicProvider    file
    AuthUserFile         "/usr/local/apache2/conf/httpd.passwd"
    Require              valid-user
</Directory>

The password used in this example is the DES encrypted string "password". See the SSLOptions docs for more information.

httpd.passwd

/C=DE/L=Munich/O=Snake Oil, Ltd./OU=Staff/CN=Foo:xxj31ZMTZzkVA
/C=US/L=S.F./O=Snake Oil, Ltd./OU=CA/CN=Bar:xxj31ZMTZzkVA
/C=US/L=L.A./O=Snake Oil, Ltd./OU=Dev/CN=Quux:xxj31ZMTZzkVA

When your clients are all part of a common hierarchy, which is encoded into the DN, you can match them more easily using SSLRequire, as follows:

SSLVerifyClient      none
SSLCACertificateFile "conf/ssl.crt/ca.crt"
SSLCACertificatePath "conf/ssl.crt"

<Directory "/usr/local/apache2/htdocs/secure/area">
  SSLVerifyClient      require
  SSLVerifyDepth       5
  SSLOptions           +FakeBasicAuth
  SSLRequireSSL
  SSLRequire       %{SSL_CLIENT_S_DN_O}  eq "Snake Oil, Ltd." \
               and %{SSL_CLIENT_S_DN_OU} in {"Staff", "CA", "Dev"}
</Directory>

How can I require HTTPS with strong ciphers, and either basic authentication or client certificates, for access to part of the Intranet website, for clients coming from the Internet? I still want to allow plain HTTP access for clients on the Intranet.

These examples presume that clients on the Intranet have IPs in the range 192.168.1.0/24, and that the part of the Intranet website you want to allow internet access to is /usr/local/apache2/htdocs/subarea. This configuration should remain outside of your HTTPS virtual host, so that it applies to both HTTPS and HTTP.

SSLCACertificateFile "conf/ssl.crt/company-ca.crt"

<Directory "/usr/local/apache2/htdocs">
    #   Outside the subarea only Intranet access is granted
    Require              ip 192.168.1.0/24
</Directory>

<Directory "/usr/local/apache2/htdocs/subarea">
    #   Inside the subarea any Intranet access is allowed
    #   but from the Internet only HTTPS + Strong-Cipher + Password
    #   or the alternative HTTPS + Strong-Cipher + Client-Certificate
    
    #   If HTTPS is used, make sure a strong cipher is used.
    #   Additionally allow client certs as alternative to basic auth.
    SSLVerifyClient      optional
    SSLVerifyDepth       1
    SSLOptions           +FakeBasicAuth +StrictRequire
    SSLRequire           %{SSL_CIPHER_USEKEYSIZE} >= 128
    
    #   Force clients from the Internet to use HTTPS
    RewriteEngine        on
    RewriteCond          "%{REMOTE_ADDR}" "!^192\.168\.1\.[0-9]+$"
    RewriteCond          "%{HTTPS}" "!=on"
    RewriteRule          "." "-" [F]
    
    #   Allow Network Access and/or Basic Auth
    Satisfy              any
    
    #   Network Access Control
    Require              ip 192.168.1.0/24
    
    #   HTTP Basic Authentication
    AuthType             basic
    AuthName             "Protected Intranet Area"
    AuthBasicProvider    file
    AuthUserFile         "conf/protected.passwd"
    Require              valid-user
</Directory>

Logging

mod_ssl can log extremely verbose debugging information to the error log, when its LogLevel is set to the higher trace levels. On the other hand, on a very busy server, level info may already be too much. Remember that you can configure the LogLevel per module to suite your needs.

التشفير القوي عبر SSL/TLS: دليل إرشادي

يهدف هذا المستند إلى مساعدتك على البدء، وتشغيل بعض الأمور. يُنصح بشدة بقراءة بقية توثيق SSL، والوصول إلى فهم أعمق للمادة، قبل الانتقال إلى التقنيات المتقدمة.

مثال على التكوين الأساسي

سيتعين أن يحتوي تكوين SSL لديك، كحد أدنى، على التوجيهات التالية.

LoadModule ssl_module modules/mod_ssl.so

Listen 443
<VirtualHost *:443>
    ServerName www.example.com
    SSLEngine on
    SSLCertificateFile "/path/to/www.example.com.cert"
    SSLCertificateKeyFile "/path/to/www.example.com.key"
</VirtualHost>

مجموعات التشفير وفرض الأمان القوي

كيف يمكنني إنشاء خادم SSL يقبل التشفير القوي فقط؟

ما يلي يفعّل أقوى الشفرات فقط:

SSLCipherSuite HIGH:!aNULL:!MD5

بينما في التكوين التالي تحدد تفضيلًا لشفرات معينة محسّنة للسرعة (والتي سيختارها mod_ssl، شريطة أن تكون مدعومة من العميل):

SSLCipherSuite RC4-SHA:AES128-SHA:HIGH:!aNULL:!MD5
SSLHonorCipherOrder on

كيف يمكنني إنشاء خادم SSL يقبل جميع أنواع الشفرات عمومًا، لكنه يتطلب شفرات قوية للوصول إلى عنوان URL معيّن؟

من الواضح أن إعدادًا على مستوى الخادم SSLCipherSuite الذي يقيّد الشفرات إلى المتغيرات القوية، ليس هو الحل هنا. ومع ذلك، mod_ssl يمكن إعادة تهيئته ضمن Location كتل، لتقديم حل على مستوى كل دليل، ويمكنه تلقائيًا فرض إعادة تفاوض على معلمات SSL لتلبية التهيئة الجديدة. يمكن القيام بذلك كما يلي:

# be liberal in general
SSLCipherSuite ALL:!aNULL:RC4+RSA:+HIGH:+MEDIUM:+LOW:+EXP:+eNULL

<Location "/strong/area">
# but https://hostname/strong/area/ and below
# requires strong ciphers
SSLCipherSuite HIGH:!aNULL:!MD5
</Location>

تدبيس OCSP

بروتوكول حالة الشهادة عبر الإنترنت (OCSP) هو آلية لتحديد ما إذا كانت شهادة الخادم قد أُلغيت أم لا، وOCSP Stapling هو شكل خاص من ذلك حيث يحتفظ الخادم، مثل httpd و mod_ssl، باستجابات OCSP الحالية لشهاداته ويرسلها إلى العملاء الذين يتواصلون مع الخادم. تحتوي معظم الشهادات على عنوان مستجيب OCSP تديره سلطة الشهادات المُصدِرة، ويمكن لـ mod_ssl التواصل مع ذلك المستجيب للحصول على استجابة موقّعة يمكن إرسالها إلى العملاء المتواصلين مع الخادم.

نظرًا لأن العميل يمكنه الحصول على حالة إلغاء الشهادة من الخادم، دون الحاجة إلى اتصال إضافي من العميل إلى سلطة الشهادات، فإن OCSP Stapling هو الطريقة المفضلة للحصول على حالة الإلغاء. وتتمثل فوائد أخرى لإزالة الاتصال بين العملاء وسلطة الشهادات في أن سجل تصفح العميل لا ينكشف لسلطة الشهادات وأن الحصول على الحالة يكون أكثر موثوقية بعدم الاعتماد على خوادم سلطة الشهادات التي قد تكون محمّلة بكثافة.

لأن الاستجابة التي يحصل عليها الخادم يمكن إعادة استخدامها لجميع العملاء الذين يستخدمون الشهادة نفسها خلال الفترة التي تكون فيها الاستجابة صالحة، فإن العبء الإضافي على الخادم ضئيل للغاية.

بمجرد تهيئة دعم SSL العام بشكل صحيح، فإن تمكين OCSP Stapling يتطلب عمومًا تعديلات طفيفة جدًا فقط على تهيئة httpd — وهي إضافة هذين التوجيهين:

SSLUseStapling On
SSLStaplingCache "shmcb:logs/ssl_stapling(32768)"

توضع هذه التوجيهات في النطاق العام (أي ليس ضمن تعريف مضيف افتراضي) حيثما توضع توجيهات تهيئة SSL العامة الأخرى، مثل في conf/extra/httpd-ssl.conf للبنى العادية مفتوحة المصدر من httpd، /etc/apache2/mods-enabled/ssl.conf لـ httpd المضمّن مع Ubuntu أو Debian، وما إلى ذلك.

المسار على SSLStaplingCache توجيه (على سبيل المثال، logs/ ) يجب أن يتطابق مع ذلك الموجود في SSLSessionCache التوجيه. هذا المسار نسبي إلى ServerRoot.

هذا بالذات SSLStaplingCache يتطلب التوجيه mod_socache_shmcb (من shmcb البادئة في وسيطة التوجيه). عادةً ما تكون هذه الوحدة مفعّلة بالفعل لـ SSLSessionCache أو نيابةً عن وحدة نمطية أخرى غير mod_ssl. إذا قمتَ بتمكين ذاكرة تخزين مؤقت لجلسات SSL باستخدام آلية غير mod_socache_shmcb، فاستخدم تلك الآلية البديلة لـ SSLStaplingCache أيضًا. على سبيل المثال:

SSLSessionCache "dbm:logs/ssl_scache"
SSLStaplingCache "dbm:logs/ssl_stapling"

يمكنك استخدام برنامج سطر الأوامر openssl للتحقق من أن استجابة OCSP تُرسل بواسطة خادمك:

$ openssl s_client -connect www.example.com:443 -status -servername www.example.com
...
OCSP response: 
======================================
OCSP Response Data:
    OCSP Response Status: successful (0x0)
    Response Type: Basic OCSP Response
...
    Cert Status: Good
...

تُبرز الأقسام التالية أكثر الحالات شيوعًا التي تتطلب مزيدًا من التعديل على التهيئة. راجع أيضًا mod_ssl الدليل المرجعي.

إذا استُخدم أكثر من عدد قليل من شهادات SSL للخادم

تُخزَّن استجابات OCSP في ذاكرة التخزين المؤقت للتدبيس الخاصة بـ SSL. وبينما تكون الاستجابات عادةً بحجم يتراوح بين بضع مئات وبضعة آلاف من البايتات، فإن mod_ssl يدعم استجابات OCSP بحجم يصل إلى نحو 10 كيلوبايت. ومع وجود أكثر من عدد قليل من الشهادات، قد يلزم زيادة حجم ذاكرة التخزين المؤقت للتدبيس (32768 بايت في المثال أعلاه). ستُسجَّل رسالة الخطأ AH01929 في حال حدوث خطأ أثناء تخزين استجابة.

إذا لم تكن الشهادة تشير إلى مستجيب OCSP، أو إذا كان يجب استخدام عنوان مختلف

ارجع إلى SSLStaplingForceURL التوجيه.

يمكنك التأكد من أن شهادة الخادم تشير إلى مستجيب OCSP باستخدام برنامج سطر الأوامر openssl، كما يلي:

$ openssl x509 -in ./www.example.com.crt -text | grep 'OCSP.*http'
OCSP - URI:http://ocsp.example.com

إذا تم توفير معرّف URI الخاص بـ OCSP وكان خادم الويب يستطيع الاتصال به مباشرةً دون استخدام وكيل، فلا يلزم أي تكوين. لاحظ أن قواعد جدار الحماية التي تتحكم في الاتصالات الصادرة من خادم الويب قد تحتاج إلى تعديل.

إذا لم يتم توفير معرّف URI خاص بـ OCSP، فاتصل بسلطة إصدار الشهادات لديك لتحديد ما إذا كان أحدها متاحًا؛ وإذا كان كذلك، فقم بتكوينه باستخدام SSLStaplingForceURL في المضيف الافتراضي الذي يستخدم الشهادة.

إذا تم تكوين عدة مضيفين افتراضيين ممكّنين لـ SSL وكان ينبغي تعطيل OCSP Stapling لبعضها

أضِف SSLUseStapling Off إلى المضيفين الافتراضيين الذين ينبغي تعطيل OCSP Stapling لهم.

إذا كان مستجيب OCSP بطيئًا أو غير موثوق

تتوفر عدة توجيهات للتعامل مع انقضاء المهلات والأخطاء. راجع الوثائق الخاصة بـ SSLStaplingFakeTryLater, SSLStaplingResponderTimeout, و SSLStaplingReturnResponderErrors التوجيهات.

إذا سجّل mod_ssl الخطأ AH02217

AH02217: ssl_stapling_init_cert: Can't retrieve issuer certificate!

لدعم OCSP Stapling عند استخدام شهادة خادم معيّنة، يجب تكوين سلسلة الشهادات لتلك الشهادة. إذا لم تكن قد كُوِّنت كجزء من تمكين SSL، فسيصدر الخطأ AH02217 عند تمكين stapling، ولن تُقدَّم استجابة OCSP للعملاء الذين يستخدمون الشهادة.

راجِع SSLCertificateChainFile و SSLCertificateFile للحصول على تعليمات لتكوين سلسلة الشهادات.

ضبط تدبيس OCSP للاستخدام في بيئة الإنتاج

إعدادات تدبيس OCSP الافتراضية محافظة وقد تؤدي إلى استعلامات مفرطة إلى مستجيبي OCSP، أو انتهاء المهلة، أو تخزين استجابات الأخطاء مؤقتًا لمدة طويلة جدًا. يُوصى بالإعدادات التالية للاستخدام في بيئة الإنتاج:

# Do not pass OCSP responder errors to clients:
SSLStaplingReturnResponderErrors off

# Reduce the OCSP responder timeout from the default 10s:
SSLStaplingResponderTimeout 4

# Cache valid OCSP responses for 48 hours (default: 1 hour).
# This reduces load on OCSP responders and avoids transient
# errors caused by frequent queries:
SSLStaplingStandardCacheTimeout 172800

# Retry failed OCSP queries after 60 seconds instead of the
# default 600s:
SSLStaplingErrorCacheTimeout 60

تعالج هذه الإعدادات مشكلات شائعة حيث ينتج تدبيس OCSP الافتراضي أخطاءً تحت الحمل — ولا سيما عندما تكون مستجيبات OCSP بطيئة أو غير موثوقة. راجع وثائق التوجيه الفردية لـSSLStaplingReturnResponderErrors, SSLStaplingResponderTimeout, SSLStaplingStandardCacheTimeout, و SSLStaplingErrorCacheTimeout للحصول على التفاصيل.

مصادقة العميل والتحكم في الوصول

كيف يمكنني إجبار العملاء على المصادقة باستخدام الشهادات؟

عندما تعرف جميع مستخدميك (على سبيل المثال، كما هو الحال غالبًا في شبكة إنترانت مؤسسية)، يمكنك اشتراط مصادقة الشهادة الصريحة. كل ما تحتاج إلى فعله هو إنشاء شهادات عميل موقَّعة بواسطة شهادة سلطة التصديق الخاصة بك (ca.crt) ثم التحقق من العملاء مقابل هذه الشهادة.

# require a client certificate which has to be directly
# signed by our CA certificate in ca.crt
SSLVerifyClient require
SSLVerifyDepth 1
SSLCACertificateFile "conf/ssl.crt/ca.crt"

كيف يمكنني إجبار العملاء على المصادقة باستخدام الشهادات من أجل عنوان URL معيّن، مع السماح للعملاء العشوائيين بالوصول إلى بقية الخادم؟

لفرض مصادقة العملاء باستخدام الشهادات من أجل عنوان URL معيّن، يمكنك استخدام ميزات إعادة التهيئة على مستوى الدليل في mod_ssl:

SSLVerifyClient none
SSLCACertificateFile "conf/ssl.crt/ca.crt"

<Location "/secure/area">
SSLVerifyClient require
SSLVerifyDepth 1
</Location>

كيف يمكنني السماح فقط للعملاء الذين لديهم شهادات بالوصول إلى عنوان URL معيّن، مع السماح لجميع العملاء بالوصول إلى بقية الخادم؟

المفتاح للقيام بذلك هو التحقق من أن جزءًا من شهادة العميل يطابق ما تتوقعه. عادةً يعني هذا التحقق من كل الاسم المميَّز (DN) أو جزء منه، لمعرفة ما إذا كان يحتوي على سلسلة معروفة. توجد طريقتان للقيام بذلك، باستخدام إما mod_auth_basic أو SSLRequire.

الـ mod_auth_basicتكون هذه الطريقة مطلوبة عمومًا عندما تكون الشهادات عشوائية تمامًا، أو عندما لا تحتوي أسماؤها المميّزة (DNs) على أي حقول مشتركة (عادةً المؤسسة، وما إلى ذلك). في هذه الحالة، ينبغي إنشاء قاعدة بيانات كلمات مرور تحتوي على جميع العملاء المسموح لهم، كما يلي:

SSLVerifyClient      none
SSLCACertificateFile "conf/ssl.crt/ca.crt"
SSLCACertificatePath "conf/ssl.crt"

<Directory "/usr/local/apache2/htdocs/secure/area">
    SSLVerifyClient      require
    SSLVerifyDepth       5
    SSLOptions           +FakeBasicAuth
    SSLRequireSSL
    AuthName             "Snake Oil Authentication"
    AuthType             Basic
    AuthBasicProvider    file
    AuthUserFile         "/usr/local/apache2/conf/httpd.passwd"
    Require              valid-user
</Directory>

كلمة المرور المستخدمة في هذا المثال هي السلسلة المشفّرة بـ DES "password". راجع وثائق SSLOptions لمزيد من المعلومات.

httpd.passwd

/C=DE/L=Munich/O=Snake Oil, Ltd./OU=Staff/CN=Foo:xxj31ZMTZzkVA
/C=US/L=S.F./O=Snake Oil, Ltd./OU=CA/CN=Bar:xxj31ZMTZzkVA
/C=US/L=L.A./O=Snake Oil, Ltd./OU=Dev/CN=Quux:xxj31ZMTZzkVA

عندما يكون جميع عملائك جزءًا من تدرّج هرمي مشترك، مُرمَّز ضمن الاسم المميّز (DN)، يمكنك مطابقتهم بسهولة أكبر باستخدام SSLRequire، كما يلي:

SSLVerifyClient      none
SSLCACertificateFile "conf/ssl.crt/ca.crt"
SSLCACertificatePath "conf/ssl.crt"

<Directory "/usr/local/apache2/htdocs/secure/area">
  SSLVerifyClient      require
  SSLVerifyDepth       5
  SSLOptions           +FakeBasicAuth
  SSLRequireSSL
  SSLRequire       %{SSL_CLIENT_S_DN_O}  eq "Snake Oil, Ltd." \
               and %{SSL_CLIENT_S_DN_OU} in {"Staff", "CA", "Dev"}
</Directory>

كيف يمكنني اشتراط HTTPS مع شيفرات قوية، وإما مصادقة أساسية أو شهادات عملاء، للوصول إلى جزء من موقع الإنترانت، للعملاء القادمين من الإنترنت؟ ما زلت أريد السماح بوصول HTTP عادي للعملاء على الإنترانت.

تفترض هذه الأمثلة أن العملاء على الإنترانت لديهم عناوين IP ضمن النطاق 192.168.1.0/24، وأن جزء موقع الإنترانت الذي تريد السماح بالوصول إليه من الإنترنت هو /usr/local/apache2/htdocs/subarea. ينبغي أن يبقى هذا التكوين خارج المضيف الافتراضي الخاص بـ HTTPS، بحيث ينطبق على كل من HTTPS وHTTP.

SSLCACertificateFile "conf/ssl.crt/company-ca.crt"

<Directory "/usr/local/apache2/htdocs">
    #   Outside the subarea only Intranet access is granted
    Require              ip 192.168.1.0/24
</Directory>

<Directory "/usr/local/apache2/htdocs/subarea">
    #   Inside the subarea any Intranet access is allowed
    #   but from the Internet only HTTPS + Strong-Cipher + Password
    #   or the alternative HTTPS + Strong-Cipher + Client-Certificate
    
    #   If HTTPS is used, make sure a strong cipher is used.
    #   Additionally allow client certs as alternative to basic auth.
    SSLVerifyClient      optional
    SSLVerifyDepth       1
    SSLOptions           +FakeBasicAuth +StrictRequire
    SSLRequire           %{SSL_CIPHER_USEKEYSIZE} >= 128
    
    #   Force clients from the Internet to use HTTPS
    RewriteEngine        on
    RewriteCond          "%{REMOTE_ADDR}" "!^192\.168\.1\.[0-9]+$"
    RewriteCond          "%{HTTPS}" "!=on"
    RewriteRule          "." "-" [F]
    
    #   Allow Network Access and/or Basic Auth
    Satisfy              any
    
    #   Network Access Control
    Require              ip 192.168.1.0/24
    
    #   HTTP Basic Authentication
    AuthType             basic
    AuthName             "Protected Intranet Area"
    AuthBasicProvider    file
    AuthUserFile         "conf/protected.passwd"
    Require              valid-user
</Directory>

تسجيل

mod_ssl يمكنه تسجيل معلومات تصحيح أخطاء شديدة الإسهاب في سجلّ الأخطاء، عندما يكون LogLevel مضبوطًا على مستويات التتبّع الأعلى. ومن ناحية أخرى، على خادم مشغول جدًا، قد يكون المستوى info أكثر من اللازم بالفعل. تذكّر أنه يمكنك تهيئة LogLevel لكل وحدة بما يلائم احتياجاتك.

Frequently asked questions · الأسئلة الشائعة

What is the purpose of the SSL/TLS strong encryption how-to?ما الغرض من دليل التشفير القوي عبر SSL/TLS؟

It is a getting-started guide for configuring Apache httpd with mod_ssl, including basic HTTPS setup, strong cipher selection, per-location cipher rules, and OCSP Stapling. The article also encourages reading the broader SSL documentation before using advanced techniques.

هو دليل تمهيدي لإعداد Apache httpd مع mod_ssl، ويشمل إعداد HTTPS الأساسي، واختيار خوارزميات تشفير قوية، وتطبيق قواعد تشفير حسب المسار، وتفعيل OCSP Stapling. كما يشجع المقال على قراءة بقية وثائق SSL قبل استخدام التقنيات المتقدمة.

When should an enterprise use server-wide strong cipher enforcement?متى تستخدم المنشأة فرض التشفير القوي على مستوى الخادم بالكامل؟

Use server-wide enforcement when the HTTPS service should accept only strong encryption for all clients and URLs. The article shows this with SSLCipherSuite HIGH:!aNULL:!MD5.

يُستخدم ذلك عندما يجب أن تقبل خدمة HTTPS التشفير القوي فقط لكل العملاء وكل الروابط. يوضح المقال ذلك باستخدام SSLCipherSuite HIGH:!aNULL:!MD5.

What are the minimum prerequisites for a basic SSL virtual host?ما المتطلبات الدنيا لإعداد مضيف افتراضي SSL أساسي؟

At minimum, the configuration needs mod_ssl loaded, port 443 listening, a VirtualHost on 443, ServerName, SSLEngine on, and paths to the certificate file and private key file using SSLCertificateFile and SSLCertificateKeyFile.

كحد أدنى، يحتاج الإعداد إلى تحميل mod_ssl، والاستماع على المنفذ 443، وتعريف VirtualHost على 443، وتحديد ServerName، وتفعيل SSLEngine on، وتحديد مسارات ملف الشهادة والمفتاح الخاص باستخدام SSLCertificateFile و SSLCertificateKeyFile.

What risk is reduced by enabling OCSP Stapling?ما المخاطر التي يقللها تفعيل OCSP Stapling؟

OCSP Stapling lets the server provide certificate revocation status to clients, reducing the need for each client to contact the Certificate Authority. This helps avoid exposing client browsing history to the Certificate Authority and improves reliability by not depending on potentially heavily loaded CA responders for every client connection.

يمكّن OCSP Stapling الخادم من تزويد العملاء بحالة إلغاء الشهادة، مما يقلل حاجة كل عميل للتواصل مع جهة إصدار الشهادة. وهذا يساعد على عدم كشف سجل تصفح العميل لجهة الإصدار، ويحسن الاعتمادية عبر عدم الاعتماد على خوادم OCSP التابعة لجهة الإصدار لكل اتصال عميل.

How can we require strong ciphers only for a specific URL area?كيف يمكننا طلب خوارزميات تشفير قوية فقط لمنطقة رابط محددة؟

Keep a broader SSLCipherSuite at the server level, then place a stricter SSLCipherSuite inside a Location block for the protected path. The article’s example uses a general cipher suite globally and SSLCipherSuite HIGH:!aNULL:!MD5 inside <Location "/strong/area">, allowing mod_ssl to renegotiate SSL parameters for that area.

يتم إبقاء SSLCipherSuite أوسع على مستوى الخادم، ثم وضع SSLCipherSuite أكثر صرامة داخل كتلة Location للمسار المحمي. يستخدم مثال المقال إعداد تشفير عام على المستوى العام و SSLCipherSuite HIGH:!aNULL:!MD5 داخل <Location "/strong/area">، مما يسمح لـ mod_ssl بإعادة التفاوض على معاملات SSL لتلك المنطقة.

How do we enable OCSP Stapling after SSL is already configured?كيف نفعّل OCSP Stapling بعد إعداد SSL مسبقاً؟

Add SSLUseStapling On and an SSLStaplingCache directive at global scope, not inside a virtual host. The cache path should match the SSLSessionCache path and is relative to ServerRoot. If using the shmcb cache prefix, mod_socache_shmcb is required.

أضف SSLUseStapling On وتوجيه SSLStaplingCache على النطاق العام، وليس داخل مضيف افتراضي. يجب أن يتطابق مسار التخزين المؤقت مع مسار SSLSessionCache، وهو مسار نسبي إلى ServerRoot. عند استخدام بادئة التخزين shmcb، يلزم توفر mod_socache_shmcb.

How can we validate that OCSP Stapling is working?كيف يمكننا التحقق من أن OCSP Stapling يعمل؟

Use the openssl command-line program with s_client, for example: openssl s_client -connect www.example.com:443 -status -servername www.example.com. A working response includes OCSP Response Status: successful and a certificate status such as Cert Status: Good.

استخدم برنامج openssl من سطر الأوامر مع s_client، مثل: openssl s_client -connect www.example.com:443 -status -servername www.example.com. الاستجابة الصحيحة تتضمن OCSP Response Status: successful وحالة شهادة مثل Cert Status: Good.

What should we check if OCSP Stapling logs error AH02217?ما الذي يجب فحصه إذا سجل OCSP Stapling الخطأ AH02217؟

AH02217 indicates that mod_ssl cannot retrieve the issuer certificate. To support OCSP Stapling for that server certificate, configure the certificate chain for the certificate. The article refers to SSLCertificateChainFile and SSLCertificateFile for chain configuration guidance.

يشير AH02217 إلى أن mod_ssl لا يستطيع جلب شهادة جهة الإصدار. لدعم OCSP Stapling لتلك الشهادة، يجب إعداد سلسلة الشهادات الخاصة بها. يشير المقال إلى SSLCertificateChainFile و SSLCertificateFile للحصول على إرشادات إعداد السلسلة.

When should an issue be escalated to the Certificate Authority or network team?متى يجب تصعيد المشكلة إلى جهة إصدار الشهادة أو فريق الشبكة؟

Contact the Certificate Authority if the server certificate does not include an OCSP URI and you need to know whether one is available. Involve the network or firewall team if the OCSP URI exists but the web server cannot communicate with it directly, because outbound firewall rules may need adjustment.

تواصل مع جهة إصدار الشهادة إذا لم تتضمن شهادة الخادم عنوان OCSP URI وتحتاج لمعرفة ما إذا كان متاحاً. وأشرك فريق الشبكة أو الجدار الناري إذا كان OCSP URI موجوداً لكن خادم الويب لا يستطيع التواصل معه مباشرة، لأن قواعد الاتصالات الصادرة قد تحتاج إلى تعديل.

What is the recommended next action for a Saudi enterprise deploying this configuration?ما الخطوة التالية الموصى بها لمنشأة سعودية تطبق هذا الإعداد؟

Start with the basic SSL virtual host, decide whether strong ciphers are required globally or only for selected URL areas, then enable and validate OCSP Stapling. For production, review the documented OCSP Stapling tuning directives such as SSLStaplingReturnResponderErrors, SSLStaplingResponderTimeout, and SSLStaplingStandardCacheTimeout before rollout.

ابدأ بإعداد المضيف الافتراضي الأساسي لـ SSL، ثم قرر هل يلزم فرض التشفير القوي على مستوى الخادم بالكامل أم فقط لمناطق روابط محددة، وبعد ذلك فعّل OCSP Stapling وتحقق من عمله. ولبيئة الإنتاج، راجع توجيهات ضبط OCSP Stapling المذكورة مثل SSLStaplingReturnResponderErrors و SSLStaplingResponderTimeout و SSLStaplingStandardCacheTimeout قبل الإطلاق.

Enterprise Infrastructure

Secure hosting, cloud and managed infrastructure for Saudi Arabia, GCC and global scale.

Saudi Sovereign

Global Cloud

24/7 Support

Enterprise Security

Enterprise Consultation

Ready to build secure, sovereign-ready digital infrastructure?

Speak with K® (Kenzie) of SAUDI GULF HOSTiNG about enterprise hosting, cloud platforms, VPS, email, cybersecurity and managed infrastructure designed for Saudi Arabia, GCC and global operations.

HostingCloudVPSEmailSecurityManaged Services
KGulf Logo