mirror of
https://github.com/NginxProxyManager/nginx-proxy-manager.git
synced 2026-10-06 10:54:41 +01:00
Fix openssl3 formatting of subject cn
This commit is contained in:
@@ -683,21 +683,15 @@ const internalCertificate = {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const result = await utils.execFile("openssl", ["x509", "-in", certificateFile, "-subject", "-noout"]);
|
const result = await utils.execFile("openssl", ["x509", "-in", certificateFile, "-subject", "-noout"]);
|
||||||
|
console.log("openssl result: ", result);
|
||||||
// Examples:
|
// Examples:
|
||||||
// subject=CN = *.jc21.com
|
// subject=CN = *.jc21.com
|
||||||
// subject=CN = something.example.com
|
// subject=CN = something.example.com
|
||||||
// CN=something.example.com
|
// subject=CN=*.jc21.com
|
||||||
const regex = /(?:subject=)?[^=]+=\s+(\S+)/gim;
|
const regex = /(?:subject=)?[^=]+=\s*(\S+)/gim;
|
||||||
const match = regex.exec(result);
|
const match = regex.exec(result);
|
||||||
if (match && typeof match[1] !== "undefined") {
|
if (match && typeof match[1] !== "undefined") {
|
||||||
certData.cn = match[1];
|
certData.cn = match[1].trim();
|
||||||
} else {
|
|
||||||
// CN is likely formatted differently
|
|
||||||
const regex11 = /CN=(\S+)/gim;
|
|
||||||
const match11 = regex11.exec(result);
|
|
||||||
if (match11 && typeof match11[1] !== "undefined") {
|
|
||||||
certData.cn = match11[1];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const result2 = await utils.execFile("openssl", ["x509", "-in", certificateFile, "-issuer", "-noout"]);
|
const result2 = await utils.execFile("openssl", ["x509", "-in", certificateFile, "-issuer", "-noout"]);
|
||||||
|
|||||||
Reference in New Issue
Block a user