Skip to content

Commit d04c6e5

Browse files
committed
Augment parseX509Output to also work with libressl
LibreSSL uses a different output separated and semantics, which broke the X509 parser. With some slight modifications both can be supported.
1 parent 2759147 commit d04c6e5

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

backend/internal/certificate.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -741,10 +741,11 @@ const internalCertificate = {
741741
*/
742742
parseX509Output: (line, prefix) => {
743743
// Remove the subject= part
744-
const subject_value = line.slice(prefix.length);
744+
const subject_value = line.slice(prefix.length).trim();
745745

746-
const subject = subject_value.split(/,(?=(?:(?:[^"]*"){2})*[^"]*$)/)
747-
.map( (e) => { return e.trim().split(' = ', 2); })
746+
const subject = subject_value.split(/[,/](?=(?:(?:[^"]*"){2})*[^"]*$)/)
747+
.filter( (e) => { return e.length > 0; } )
748+
.map( (e) => { return e.trim().split('=', 2).map( (p) => { return p.trim(); }); })
748749
.reduce((obj, [key, value]) => {
749750
obj[key] = value.replace(/^"/, '').replace(/"$/, '');
750751
return obj;

0 commit comments

Comments
 (0)