Use try with resources when handling FileStreams

This commit is contained in:
CommentSectionScientist 2020-04-10 19:57:01 +02:00
parent f9fce08e6c
commit 5ba4d9c26e
1 changed files with 3 additions and 3 deletions

View File

@ -1008,9 +1008,9 @@ public final class SecurityUtils {
getCertificateChain(contractCertChain));
// Save the keystore persistently
FileOutputStream fos = new FileOutputStream("evccKeystore.jks");
keyStore.store(fos, GlobalValues.PASSPHRASE_FOR_CERTIFICATES_AND_KEYS.toString().toCharArray());
fos.close();
try(FileOutputStream fos = new FileOutputStream("evccKeystore.jks")){
keyStore.store(fos, GlobalValues.PASSPHRASE_FOR_CERTIFICATES_AND_KEYS.toString().toCharArray());
}
X509Certificate contractCert = getCertificate(contractCertChain.getCertificate());