summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--vespa-athenz/src/main/java/com/yahoo/vespa/athenz/utils/SiaUtils.java7
1 files changed, 3 insertions, 4 deletions
diff --git a/vespa-athenz/src/main/java/com/yahoo/vespa/athenz/utils/SiaUtils.java b/vespa-athenz/src/main/java/com/yahoo/vespa/athenz/utils/SiaUtils.java
index 4d7f4b1c397..12a8c3f911e 100644
--- a/vespa-athenz/src/main/java/com/yahoo/vespa/athenz/utils/SiaUtils.java
+++ b/vespa-athenz/src/main/java/com/yahoo/vespa/athenz/utils/SiaUtils.java
@@ -97,7 +97,7 @@ public class SiaUtils {
Files.createDirectories(privateKeyFile.getParent());
Path tempFile = toTempFile(privateKeyFile);
Files.write(tempFile, KeyUtils.toPem(privateKey).getBytes());
- Files.move(tempFile, privateKeyFile, StandardCopyOption.ATOMIC_MOVE);
+ Files.move(tempFile, privateKeyFile, StandardCopyOption.ATOMIC_MOVE, StandardCopyOption.REPLACE_EXISTING);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
@@ -113,7 +113,7 @@ public class SiaUtils {
Files.createDirectories(certificateFile.getParent());
Path tempFile = toTempFile(certificateFile);
Files.write(tempFile, X509CertificateUtils.toPem(certificate).getBytes());
- Files.move(tempFile, certificateFile, StandardCopyOption.ATOMIC_MOVE);
+ Files.move(tempFile, certificateFile, StandardCopyOption.ATOMIC_MOVE, StandardCopyOption.REPLACE_EXISTING);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
@@ -142,7 +142,6 @@ public class SiaUtils {
}
private static Path toTempFile(Path file) {
- return Paths.get(file.toAbsolutePath().toString() + ".tmp");
+ return file.getParent().resolve(file.getFileName().toString() + ".tmp");
}
-
}