将密码短语添加到环境变量 (bashrc) 以便在重新启动 Apache 服务器时使用

Add Pass phrase to environment variables (bashrc) in order to be used when restarting Apache server

目前我在 [=45 上使用 "SSLPassPhraseDialog exec:/path/to/pass-phrase.sh" =].conf 文件

#!/bin/bash
echo "mypassphrase"

当我重新启动或启动我的 apache 服务器时一切正常。

我试图将我的密码添加到我的 .bashrc 中,就像这样 export SSL_PASSPHRASE=mypassphrase

并获取 .bashrc 文件 source ~/.bashrc

之后我把pass-phrase.sh改成了

#!/bin/bash
echo $SSL_PASSPHRASE

执行./path/to/pass-phrase.sh结果到mypassphrase

但是当我尝试重新启动我的 Apache 服务器时,发生了与密码相关的错误

> [Mon Dec 16 22:56:59.611824 2019] [ssl:emerg] [pid 19314] AH02580:
> Init: Pass phrase incorrect for key mysub.myinstance.com:443:0 [Mon Dec
> 16 22:56:59.611883 2019] [ssl:emerg] [pid 19314] SSL Library Error:
> error:0D0680A8:asn1 encoding routines:asn1_check_tlen:wrong tag [Mon
> Dec 16 22:56:59.611892 2019] [ssl:emerg] [pid 19314] SSL Library
> Error: error:0D08303A:asn1 encoding
> routines:asn1_template_noexp_d2i:nested asn1 error [Mon Dec 16
> 22:56:59.611898 2019] [ssl:emerg] [pid 19314] SSL Library Error:
> error:0D0680A8:asn1 encoding routines:asn1_check_tlen:wrong tag [Mon
> Dec 16 22:56:59.611905 2019] [ssl:emerg] [pid 19314] SSL Library
> Error: error:0D07803A:asn1 encoding
> routines:asn1_item_embed_d2i:nested asn1 error (Type=RSAPrivateKey)
> [Mon Dec 16 22:56:59.611912 2019] [ssl:emerg] [pid 19314] SSL Library
> Error: error:04093004:rsa routines:old_rsa_priv_decode:RSA lib [Mon
> Dec 16 22:56:59.611937 2019] [ssl:emerg] [pid 19314] SSL Library
> Error: error:0D0680A8:asn1 encoding routines:asn1_check_tlen:wrong tag
> [Mon Dec 16 22:56:59.611947 2019] [ssl:emerg] [pid 19314] SSL Library
> Error: error:0D07803A:asn1 encoding
> routines:asn1_item_embed_d2i:nested asn1 error
> (Type=PKCS8_PRIV_KEY_INFO) [Mon Dec 16 22:56:59.613065 2019]
> [ssl:emerg] [pid 19314] AH02564: Failed to configure encrypted (?)
> private key mysub.myinstance.com:443:0, check
> /etc/apache2/ssl/mykey.key

.bashrc 配置您的环境。

Apache 有时会配置 sudo 以绑定低于 1024 的端口。您可能有 UserGroup 指令来定义 Apache 启动后将切换到哪个用户。

所有这些都说明您的 Apache 运行在与您的用户不同的环境中。它无权访问变量。

放置这些变量的"right"地方在$APACHE_ROOT/bin/envvars