Trim newlines

merge-requests/2/merge
Bsian 2019-12-30 16:57:34 +00:00
parent c1538538eb
commit 591ced7c06
No known key found for this signature in database
GPG Key ID: 097FB9A291026091
1 changed files with 8 additions and 8 deletions

View File

@ -46,18 +46,18 @@ export default class CWG_UpdateCert extends Command {
} }
public isValidCertificateChain(cert: string) { public isValidCertificateChain(cert: string) {
if (!cert.startsWith('-----BEGIN CERTIFICATE-----')) return false; if (!cert.replace(/^\s+|\s+$/g, '').startsWith('-----BEGIN CERTIFICATE-----')) return false;
if (!cert.endsWith('-----END CERTIFICATE-----')) return false; if (!cert.replace(/^\s+|\s+$/g, '').endsWith('-----END CERTIFICATE-----')) return false;
if (this.checkOccurance(cert, '-----BEGIN CERTIFICATE-----') !== 2) return false; if (this.checkOccurance(cert.replace(/^\s+|\s+$/g, ''), '-----BEGIN CERTIFICATE-----') !== 2) return false;
if (this.checkOccurance(cert, '-----END CERTIFICATE-----') !== 2) return false; if (this.checkOccurance(cert.replace(/^\s+|\s+$/g, ''), '-----END CERTIFICATE-----') !== 2) return false;
return true; return true;
} }
public isValidPrivateKey(key: string) { public isValidPrivateKey(key: string) {
if (!key.startsWith('-----BEGIN PRIVATE KEY-----')) return false; if (!key.replace(/^\s+|\s+$/g, '').startsWith('-----BEGIN PRIVATE KEY-----')) return false;
if (!key.endsWith('-----END PRIVATE KEY-----')) return false; if (!key.replace(/^\s+|\s+$/g, '').endsWith('-----END PRIVATE KEY-----')) return false;
if (this.checkOccurance(key, '-----BEGIN PRIVATE KEY-----') !== 1) return false; if (this.checkOccurance(key.replace(/^\s+|\s+$/g, ''), '-----BEGIN PRIVATE KEY-----') !== 1) return false;
if (this.checkOccurance(key, '-----END PRIVATE KEY-----') !== 1) return false; if (this.checkOccurance(key.replace(/^\s+|\s+$/g, ''), '-----END PRIVATE KEY-----') !== 1) return false;
return true; return true;
} }
} }