无效命令 'SSLOpenSSLConfCmd',可能拼写错误或由服务器配置中未包含的模块定义

像其他管理员一样,我正在处理Logjam fix。 我已经在我的CentOS 6.6服务器上升级到Apache 2.4.12和OpenSSL 1.0.2a。 当我启动Apache时,我看到返回了这个错误信息:
Invalid command 'SSLOpenSSLConfCmd', perhaps misspelled or defined by a module not included in the server configuration
这是我的Apache构建信息:
Server version: Apache/2.4.12 (Unix)
Server built:   Jun  8 2015 22:04:38
Server's Module Magic Number: 20120211:41
Server loaded:  APR 1.4.5, APR-UTIL 1.3.12
Compiled using: APR 1.4.5, APR-UTIL 1.3.12
Architecture:   64-bit
Server MPM:     worker
  threaded:     yes (fixed thread count)
    forked:     yes (variable process count)
Server compiled with....
 -D APR_HAS_SENDFILE
 -D APR_HAS_MMAP
 -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
 -D APR_USE_SYSVSEM_SERIALIZE
 -D APR_USE_PTHREAD_SERIALIZE
 -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
 -D APR_HAS_OTHER_CHILD
 -D AP_HAVE_RELIABLE_PIPED_LOGS
 -D DYNAMIC_MODULE_LIMIT=256
 -D HTTPD_ROOT="/opt/installs/apache/2_4_12"
 -D SUEXEC_BIN="/opt/installs/apache/2_4_12/bin/suexec"
 -D DEFAULT_PIDLOG="logs/httpd.pid"
 -D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
 -D DEFAULT_ERRORLOG="logs/error_log"
 -D AP_TYPES_CONFIG_FILE="conf/mime.types"
 -D SERVER_CONFIG_FILE="conf/httpd.conf"    

mod_ssl已包含在我的httpd.conf文件中:

LoadModule ssl_module modules/mod_ssl.so
我错过了什么?

1weakdh.org/sysadmin网站在此之前(截至目前)存在错别字/不准确之处:http://serverfault.com/questions/706014/tomcat-solution-on-https-weakdh-org-has-typos - austinian
3个回答

SSLOpenSSLConfCmd 仅适用于 httpd 2.4.8 以后的版本。

然而,在早期版本中,您仍然可以生成和使用自己的 DH 参数,如此处所述 here

如果您正在使用带有LibreSSL的Apache,或者Apache 2.4.7和OpenSSL 0.9.8a或更高版本,您可以将之前生成的DH参数追加到证书文件的末尾。相关文档在这里和下面提供: 还可以将自定义的DH参数和临时密钥的EC曲线名称添加到使用SSLCertificateFile配置的第一个文件的末尾。此功能支持2.4.7版本或更高版本。可以使用openssl dhparam和openssl ecparam命令生成这些参数。将参数原样添加到第一个证书文件的末尾即可。只能使用第一个文件来设置自定义参数,因为它们与身份验证算法类型无关。 只需使用cat命令将dhparams.pem追加到您的证书文件中即可。
cat dhparams.pem >> cert.pem

根据Apache文档 - 可用的SSLOpenSSLConfCmd命令集取决于所使用的OpenSSL版本(至少需要1.0.2版本)来进行mod_ssl。有关支持的命令名称列表,请参阅OpenSSL的SSL_CONF_cmd(3)手册页中支持的配置文件命令部分。 请使用SSLOpenSSLConfCmd验证您正在使用的命令。

我在openssl.org的文档中找不到任何关于“SSLOpenSSLConfCmd”命令的参考。 - ryanlraines
你可能在你的httpd.conf或自定义配置文件(conf.d/*)中使用了SSLOpenSSLConfCmd命令名和命令值。 http://httpd.apache.org/docs/trunk/mod/mod_ssl.html - chetangb

SSLOpenSSLConfCmd指令在httpd 2.4.8(尚未发布)及之后的版本中可用,如果使用OpenSSL 1.0.2或更高版本。

Apache 2.4.8的变化(尚未发布)... mod_ssl:通过引入SSLOpenSSLConfCmd指令,添加对OpenSSL配置命令的支持。[Stephen Henson,Kaspar Brand] ...

构建APR

# ./configure --host=x86_64-redhat-linux-gnu --build=x86_64-redhat-linux-gnu --prefix=/opt/apr-1.5.2 --with-devrandom=/dev/urandom
构建APR-UTIL
# ./configure --prefix=/opt/apr-util-1.5.4 --with-ldap --with-crypto --with-openssl=/opt/openssl-1.0.2a --with-apr=/opt/apr-1.5.2
构建Apache
# ./configure --prefix=/opt/httpd-2.4.12 --enable-mpms-shared=all --with-pcre --enable-mods-shared=all --enable-ssl --with-ssl=/opt/openssl-1.0.2a --with-apr=/opt/apr-1.5.2 --with-apr-util=/opt/apr-util-1.5.4 --enable-session-crypto
...
configure:
  setting INCLUDES to "-I."
  adding "-I$(top_srcdir)/os/$(OS_DIR)" to INCLUDES
  adding "-I$(top_srcdir)/include" to INCLUDES
  adding "-I/opt/apr-1.5.2/include/apr-1" to INCLUDES
  adding "-I/opt/apr-util-1.5.4/include/apr-1" to INCLUDES
  adding "-I/opt/openssl-1.0.2a/include" to INCLUDES
...
检查 mod_ssl.so
# ldd mod_ssl.so | grep ssl
        libssl.so.1.0.0 => /opt/openssl-1.0.2a/lib/libssl.so.1.0.0 (0x00007f6f3c6bd000)
        libcrypto.so.1.0.0 => /opt/openssl-1.0.2a/lib/libcrypto.so.1.0.0 (0x00007f6f3c287000)

# strings mod_ssl.so | grep SSLOpenSSLConfCmd
SSLOpenSSLConfCmd
AH02407: "SSLOpenSSLConfCmd %s %s" failed for %s
AH02556: "SSLOpenSSLConfCmd %s %s" applied to %s
检查Apache设置
# ./httpd -v
Server version: Apache/2.4.12 (Unix)
Server built:   Mar 27 2016 16:29:30

# ./httpd -V
Server version: Apache/2.4.12 (Unix)
Server built:   Mar 27 2016 16:29:30
Server's Module Magic Number: 20120211:41
Server loaded:  APR 1.5.2, APR-UTIL 1.5.4
Compiled using: APR 1.5.2, APR-UTIL 1.5.4
Architecture:   64-bit
Server MPM:     event
  threaded:     yes (fixed thread count)
    forked:     yes (variable process count)
Server compiled with....
 -D APR_HAS_SENDFILE
 -D APR_HAS_MMAP
 -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
 -D APR_USE_SYSVSEM_SERIALIZE
 -D APR_USE_PTHREAD_SERIALIZE
 -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
 -D APR_HAS_OTHER_CHILD
 -D AP_HAVE_RELIABLE_PIPED_LOGS
 -D DYNAMIC_MODULE_LIMIT=256
 -D HTTPD_ROOT="/opt/httpd-2.4.12"
 -D SUEXEC_BIN="/opt/httpd-2.4.12/bin/suexec"
 -D DEFAULT_PIDLOG="logs/httpd.pid"
 -D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
 -D DEFAULT_ERRORLOG="logs/error_log"
 -D AP_TYPES_CONFIG_FILE="conf/mime.types"
 -D SERVER_CONFIG_FILE="conf/httpd.conf"

# /opt/httpd-2.4.12/bin/apachectl -t
Syntax OK
虚拟主机设置
# conf/extra/httpd-ssl.conf
Listen 443
SSLOpenSSLConfCmd DHParameters /etc/pki/httpd/dhparams_2048.pem
SSLCipherSuite kEECDH+AES128:kEECDH:kEDH:-3DES:kRSA+AES128:kEDH+3DES:DES-CBC3-SHA:!RC4:!aNULL:!eNULL:!MD5:!EXPORT:!LOW:!SEED:!CAMELLIA:!IDEA:!PSK:!SRP:!SSLv2
SSLHonorCipherOrder on
SSLPassPhraseDialog  builtin
SSLSessionCache "shmcb:/opt/httpd-2.4.12/logs/ssl_scache(512000)"
SSLSessionCacheTimeout  300
SSLProtocol All -SSLv2 -SSLv3

<VirtualHost _default_:443>

   DocumentRoot "/opt/httpd-2.4.12/htdocs"
   ServerName ssllabs.example.com:443
   ServerAdmin webmaster@example.com
   ErrorLog "/opt/httpd-2.4.12/logs/error_log"
   TransferLog "/opt/httpd-2.4.12/logs/access_log"

   SSLEngine on
   SSLCertificateFile /etc/pki/httpd/server.pem
   SSLCertificateKeyFile /etc/pki/httpd/server.key

   <FilesMatch "\.(cgi|shtml|phtml|php)$">
       SSLOptions +StdEnvVars
   </FilesMatch>
   <Directory "/opt/httpd-2.4.12/cgi-bin">
       SSLOptions +StdEnvVars
   </Directory>

   BrowserMatch "MSIE [2-5]" nokeepalive ssl-unclean-shutdown downgrade-1.0 force-response-1.0
   CustomLog "/opt/httpd-2.4.12/logs/ssl_request_log" "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"

</VirtualHost>
测试结果

enter image description here

enter image description here