hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Hanson Char (JIRA)" <j...@apache.org>
Subject [jira] Commented: (HTTPCLIENT-641) Resource Leakage when loading keystore in AuthSSLProtocolSocketFactory
Date Sun, 04 Mar 2007 04:58:50 GMT

    [ https://issues.apache.org/jira/browse/HTTPCLIENT-641?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12477740
] 

Hanson Char commented on HTTPCLIENT-641:
----------------------------------------

Further browsing of the httpclient library find similar bugs exist in

  org.apache.commons.httpclient.ssl.SimpleSSLSocketFactory#createSSLContext()

Nice to have it fixed as well.  Thanks in advance!

> Resource Leakage when loading keystore in AuthSSLProtocolSocketFactory
> ----------------------------------------------------------------------
>
>                 Key: HTTPCLIENT-641
>                 URL: https://issues.apache.org/jira/browse/HTTPCLIENT-641
>             Project: HttpComponents HttpClient
>          Issue Type: Bug
>          Components: Contrib
>    Affects Versions: 3.0.1
>         Environment: All
>            Reporter: Hanson Char
>             Fix For: 3.0.1
>
>
> Opened stream not closed after keystore is loaded, resulting in resource leakage:
> private static KeyStore createKeyStore(final URL url, final String password) 
>         throws KeyStoreException, NoSuchAlgorithmException, CertificateException, IOException
>     {
>         if (url == null) {
>             throw new IllegalArgumentException("Keystore url may not be null");
>         }
>         LOG.debug("Initializing key store");
>         KeyStore keystore  = KeyStore.getInstance("jks");
>         keystore.load(url.openStream(), password != null ? password.toCharArray(): null);
>         return keystore;
>     }
> Should be changed to something like:
> private static KeyStore createKeyStore(final URL url, final String password) 
>         throws KeyStoreException, NoSuchAlgorithmException, CertificateException, IOException
>     {
>         if (url == null) {
>             throw new IllegalArgumentException("Keystore url may not be null");
>         }
>         LOG.debug("Initializing key store");
>         KeyStore keystore  = KeyStore.getInstance("jks");
>         InputStream is = ulr.openStream();
>         try {
>           keystore.load(is, password != null ? password.toCharArray(): null);
>         } finally {
>            is.close();
>         }
>         return keystore;
>     }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: httpcomponents-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpcomponents-dev-help@jakarta.apache.org


Mime
View raw message