Github user jburwell commented on a diff in the pull request: https://github.com/apache/cloudstack/pull/1511#discussion_r78648029 --- Diff: utils/src/main/java/com/cloud/utils/security/CertificateHelper.java --- @@ -38,125 +38,139 @@ import java.security.spec.InvalidKeySpecException; import java.security.spec.PKCS8EncodedKeySpec; import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; import java.util.List; -import com.cloud.utils.exception.CloudRuntimeException; import org.apache.commons.codec.binary.Base64; +import org.bouncycastle.util.io.pem.PemObject; +import org.bouncycastle.util.io.pem.PemReader; import com.cloud.utils.Ternary; -import org.bouncycastle.openssl.PEMReader; +import com.cloud.utils.exception.CloudRuntimeException; public class CertificateHelper { - public static byte[] buildAndSaveKeystore(String alias, String cert, String privateKey, String storePassword) throws KeyStoreException, CertificateException, - NoSuchAlgorithmException, InvalidKeySpecException, IOException { - KeyStore ks = buildKeystore(alias, cert, privateKey, storePassword); + public static byte[] buildAndSaveKeystore(final String alias, final String cert, final String privateKey, final String storePassword) throws KeyStoreException, CertificateException, + NoSuchAlgorithmException, InvalidKeySpecException, IOException { + final KeyStore ks = buildKeystore(alias, cert, privateKey, storePassword); - ByteArrayOutputStream os = new ByteArrayOutputStream(); + final ByteArrayOutputStream os = new ByteArrayOutputStream(); ks.store(os, storePassword != null ? storePassword.toCharArray() : null); os.close(); --- End diff -- It appears that we potentially leaving a dangling `OutputSteam` instance here. It seems like lines 57 and 58 should be wrapped in a try with resources block that translates all checked exceptions to unchecked exceptions and logs the error.
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---