Windows 10下安装Discuz!Q出现openssl相关错误解决方法

本文系统为Windows 10 64位,采用wampserver3.2.3_x64集成环境在e盘,PHP 7.4.23为例:
安装Discuz!Q时提示的错误信息为:
"error:0E06D06C:configuration file routines:NCONF_get_string:no value"
经过一波神操作后,发现openssl的配置文件有错:

php测试代码,:

# 查看当前系统环境中openssl.cnf默认的位置,
echo getenv('OPENSSL_CONF');

输出结果显示:
c:\apache24\conf\openssl.cnf
这里我们采用补全,或者新增系统环境变量:
新建系统变量:OPENSSL_CONF
值:E:\apache24\conf\openssl.cnf

注意:apache下的openssl.cnf需要与当前PHP版本下\extras\ssl\openssl.cnf保持一致,

本地测试生成key的文件:

<?php
// apache路径下的openssl.conf文件路径
$opensslConfigPath = "E:/path/apache/conf/openssl.cnf";
$opensslConfigPath = "E:/apache24/conf/openssl.cnf";
// 查看openssl.cnf路径
var_dump(getenv('OPENSSL_CONF'));
$dn = array(
"countryName" => 'XX', //所在国家名称
"stateOrProvinceName" => 'State', //所在省份名称
"localityName" => 'SomewhereCity', //所在城市名称
"organizationName" => 'MySelf', //注册人姓名
"organizationalUnitName" => 'Whatever', //组织名称
"commonName" => 'mySelf', //公共名称
"emailAddress" => 'user@domain.com' //邮箱
);
$privkeypass = '111111'; //私钥密码
$numberofdays = 365; //有效时长
$cerpath = "./test.cer"; //生成证书路径
$pfxpath = "./test.pfx"; //密钥文件路径
$config = array(
'private_key_bits' => 2048,
'config' => $opensslConfigPath
);
//生成证书
$privkey = openssl_pkey_new($config);
var_dump('1#openssl_pkey_new::::');var_dump ($privkey);
$configargs = array('config'=>$opensslConfigPath);
$csr = openssl_csr_new($dn, $privkey,$configargs);
var_dump('2#openssl_csr_new::::');var_dump($csr);
$sscert = openssl_csr_sign($csr, null, $privkey, $numberofdays, $configargs);
var_dump('3#openssl_csr_sign::::');var_dump($sscert);
openssl_x509_export($sscert, $csrkey); //导出证书$csrkey
openssl_pkcs12_export($sscert, $privatekey, $privkey, $privkeypass); //导出密钥$privatekey
//生成证书文件
$fp = fopen($cerpath, "w");
fwrite($fp, $csrkey);
fclose($fp);
//生成密钥文件
$fp = fopen($pfxpath, "w");
fwrite($fp, $privatekey);
fclose($fp);

如果配置成功,会生成test.cer和test.pfx文件 ,以下test.cer文件:

-----BEGIN CERTIFICATE-----
MIID5DCCAsygAwIBAgIBADANBgkqhkiG9w0BAQUFADCBijELMAkGA1UEBhMCWFgx
DjAMBgNVBAgMBVN0YXRlMRYwFAYDVQQHDA1Tb21ld2hlcmVDaXR5MQ8wDQYDVQQK
DAZNeVNlbGYxETAPBgNVBAsMCFdoYXRldmVyMQ8wDQYDVQQDDAZteVNlbGYxHjAc
BgkqhkiG9w0BCQEWD3VzZXJAZG9tYWluLmNvbTAeFw0yMTA5MDEwNzM0MzZaFw0y
MjA5MDEwNzM0MzZaMIGKMQswCQYDVQQGEwJYWDEOMAwGA1UECAwFU3RhdGUxFjAU
BgNVBAcMDVNvbWV3aGVyZUNpdHkxDzANBgNVBAoMBk15U2VsZjERMA8GA1UECwwI
V2hhdGV2ZXIxDzANBgNVBAMMBm15U2VsZjEeMBwGCSqGSIb3DQEJARYPdXNlckBk
b21haW4uY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA19o4KJyT
1IBRS4g3IF1HWqpFJ8TchsfLtdjkitb6lukxjTP6zcDkwOdS0kkr9SWJMX2u5X7j
VmaakVzldO/uyfvkgdJp0MMNkkYqiIF9+0kWJkUHWYkDHQGAwJsUWPgb2QIRuNnT
sZs4us+R/OEwuSdB+VWeSozmBvU9n6swWDkgTYkn3jv0StbovLCQZErISWlg429H
nu6KyVZvrcMh12Roz7hdP/D0VV5bnlkStcCYX5wyOGgy4SwMFjAazIuK7C2RTpL/
LHaLFwepiP9BtLYwfue/9AkhIxUPTO6Kjczwigpk1L75gf1FX5FDHURj2WfN4JTB
vJw3whcAnEYRdwIDAQABo1MwUTAdBgNVHQ4EFgQUaTTL6GJcP5+lJF6e9qeH5w2a
zUUwHwYDVR0jBBgwFoAUaTTL6GJcP5+lJF6e9qeH5w2azUUwDwYDVR0TAQH/BAUw
AwEB/zANBgkqhkiG9w0BAQUFAAOCAQEAM+nB7IwefMyUmQLoW9A+MzcmKI5MVn0I
KzfTYcwORpbh7NuUeVHwpxI+8AjEWCrff1meLB/e65CmQ3tdebdpIZh56ZVoQXdW
0gpi98nxYr0p41+s6mpbZrmHvC6MNReCclgLdGjClOMzkRV179w9l3jyeSAmHkO7
RupCO+BxLQiXLWfolNcw94vOxkMD61irJh8DBtGBhk7LtV5kMazhhvPlw19gmIsK
DWdh1XKgSsqWO7o5YguK3uH9ioJVo9lVE6/Bgk9dTlIwfMeayD4bAd7OpmvAMpWp
tBwQv3SYtxrVesYIKR54THDFVORv28ba3wytZ1VHZM5DIhoAgp1mCw==
-----END CERTIFICATE-----

转载请注明出处:https://www.onexin.net/windows-10-discuzq-openssl/

相关文章:

1、DiscuzX3.4转换DiscuzQ 3.0工具
https://www.onexin.net/discuzx34-to-discuzq30/

2、Discuz!Q 升级 v2.3.210202 版本后,进行红蓝主题切换时报错 Warning: shell_exec() has been disabled for security reasons in 如何解决?
https://www.onexin.net/discuzq-v2-3-210202-warning-shell_exec-ha/

3、Discuz!Q 安装后,首屏无限加载如何解决?
https://www.onexin.net/discuzq-load/

4、Discuz!Q 安装后图片不能显示(没使用对象存储)怎么办?
https://www.onexin.net/discuzq-storage/

5、Discuz!Q 容器的更多配置说明?
https://www.onexin.net/discuzq-docker/

Leave a Reply