大改:重构项目
This commit is contained in:
@@ -111,12 +111,17 @@ public class CertificateLoader {
|
|||||||
* 从Docker挂载卷加载证书
|
* 从Docker挂载卷加载证书
|
||||||
*/
|
*/
|
||||||
private String loadFromVolume(String certPath) {
|
private String loadFromVolume(String certPath) {
|
||||||
|
log.debug("尝试从Docker挂载卷加载证书:{}", certPath);
|
||||||
|
|
||||||
// 如果是完整路径,直接使用
|
// 如果是完整路径,直接使用
|
||||||
if (certPath.startsWith("/") || certPath.contains(":")) {
|
if (certPath.startsWith("/") || certPath.contains(":")) {
|
||||||
File file = new File(certPath);
|
File file = new File(certPath);
|
||||||
|
log.debug("检查完整路径文件是否存在:{}", certPath);
|
||||||
if (file.exists()) {
|
if (file.exists()) {
|
||||||
log.debug("使用完整路径加载证书:{}", certPath);
|
log.debug("使用完整路径加载证书:{}", certPath);
|
||||||
return certPath;
|
return certPath;
|
||||||
|
} else {
|
||||||
|
log.error("完整路径文件不存在:{}", certPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -278,20 +278,42 @@ import com.gxwebsoft.common.core.service.PaymentCacheService;
|
|||||||
System.out.println("证书加载完成 - 私钥文件: " + privateKey);
|
System.out.println("证书加载完成 - 私钥文件: " + privateKey);
|
||||||
System.out.println("使用自动证书配置,无需手动加载微信支付平台证书");
|
System.out.println("使用自动证书配置,无需手动加载微信支付平台证书");
|
||||||
} else {
|
} else {
|
||||||
// 生产环境配置 - 从容器证书目录加载,包含租户号
|
// 生产环境配置 - 从容器证书目录加载
|
||||||
final String certRootPath = certConfig.getCertRootPath(); // /www/wwwroot/file.ws
|
final String certRootPath = certConfig.getCertRootPath(); // /www/wwwroot/file.ws
|
||||||
final String tenantCertPath = certRootPath + "/wechat/" + order.getTenantId();
|
final String certBasePath = certRootPath + "/file"; // 实际文件存储路径
|
||||||
|
|
||||||
System.out.println("生产环境证书路径 - 租户ID: " + order.getTenantId());
|
System.out.println("生产环境证书路径 - 租户ID: " + order.getTenantId());
|
||||||
System.out.println("生产环境证书根路径: " + tenantCertPath);
|
System.out.println("生产环境证书根路径: " + certRootPath);
|
||||||
|
System.out.println("生产环境证书基础路径: " + certBasePath);
|
||||||
|
System.out.println("私钥文件名: " + payment.getApiclientKey());
|
||||||
|
System.out.println("证书文件名: " + payment.getApiclientCert());
|
||||||
|
|
||||||
|
// 构建完整的证书文件路径
|
||||||
|
// 处理数据库路径可能以/开头的情况,避免双斜杠
|
||||||
|
String privateKeyRelativePath = payment.getApiclientKey();
|
||||||
|
String apiclientCertRelativePath = payment.getApiclientCert();
|
||||||
|
|
||||||
|
// 如果数据库路径以/开头,直接拼接;否则添加/
|
||||||
|
String privateKeyFullPath = privateKeyRelativePath.startsWith("/")
|
||||||
|
? certBasePath + privateKeyRelativePath
|
||||||
|
: certBasePath + "/" + privateKeyRelativePath;
|
||||||
|
String apiclientCertFullPath = apiclientCertRelativePath.startsWith("/")
|
||||||
|
? certBasePath + apiclientCertRelativePath
|
||||||
|
: certBasePath + "/" + apiclientCertRelativePath;
|
||||||
|
|
||||||
|
System.out.println("私钥完整路径: " + privateKeyFullPath);
|
||||||
|
System.out.println("证书完整路径: " + apiclientCertFullPath);
|
||||||
|
|
||||||
|
privateKey = certificateLoader.loadCertificatePath(privateKeyFullPath);
|
||||||
|
apiclientCert = certificateLoader.loadCertificatePath(apiclientCertFullPath);
|
||||||
|
|
||||||
privateKey = certificateLoader.loadCertificatePath(
|
|
||||||
tenantCertPath + "/" + payment.getApiclientKey());
|
|
||||||
apiclientCert = certificateLoader.loadCertificatePath(
|
|
||||||
tenantCertPath + "/" + payment.getApiclientCert());
|
|
||||||
if (payment.getPubKey() != null && !payment.getPubKey().isEmpty()) {
|
if (payment.getPubKey() != null && !payment.getPubKey().isEmpty()) {
|
||||||
pubKey = certificateLoader.loadCertificatePath(
|
String pubKeyRelativePath = payment.getPubKey();
|
||||||
tenantCertPath + "/" + payment.getPubKey());
|
String pubKeyFullPath = pubKeyRelativePath.startsWith("/")
|
||||||
|
? certBasePath + pubKeyRelativePath
|
||||||
|
: certBasePath + "/" + pubKeyRelativePath;
|
||||||
|
System.out.println("公钥完整路径: " + pubKeyFullPath);
|
||||||
|
pubKey = certificateLoader.loadCertificatePath(pubKeyFullPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user