Skip to content

Commit

Permalink
Delete certificate before writing
Browse files Browse the repository at this point in the history
Closes qzind#796
  • Loading branch information
lite1979 committed May 3, 2021
1 parent 6b39f81 commit a0127c8
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/qz/installer/certificate/CertificateManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,10 @@ public CertificateManager createTrustedKeystore(File pemKey, File pemCert) throw
}

public static void writeCert(X509Certificate data, File dest) throws IOException {
// PEMWriter doesn't always clear the file, explicitly delete it, see issue #796
if(dest.exists()) {
dest.delete();
}
JcaMiscPEMGenerator cert = new JcaMiscPEMGenerator(data);
JcaPEMWriter writer = new JcaPEMWriter(new OutputStreamWriter(Files.newOutputStream(dest.toPath(), StandardOpenOption.CREATE)));
writer.writeObject(cert.generate());
Expand Down

0 comments on commit a0127c8

Please sign in to comment.