public final class CertificateUtil extends Object
Modifier and Type | Method and Description |
---|---|
static List<X509Certificate> |
fetchCertificates(String url)
Fetches certificates associated with the URL host.
|
static List<X509Certificate> |
fetchCertificates(String host,
int port)
Fetches certificates associated with the given host and port.
|
static boolean |
isTrusted(String host,
int port,
KeyStore keyStore)
Gets whether a host is trusted by the given key store.
|
static String |
toString(List<X509Certificate> certificates)
Returns a friendly string display of certificates.
|
static int |
trustHost(String host,
int port,
KeyStore keyStore)
Trusts a host.
|
static int |
trustHost(String url,
KeyStore keyStore)
Trusts the URL host.
|
public static List<X509Certificate> fetchCertificates(String url) throws GeneralSecurityException, IOException
url
- url from which to fetch certificatesGeneralSecurityException
- certificate exceptionIOException
- I/O exceptionpublic static List<X509Certificate> fetchCertificates(String host, int port) throws GeneralSecurityException, IOException
host
- from which to fetch certificatesport
- host portGeneralSecurityException
- certificate exceptionIOException
- I/O exceptionpublic static boolean isTrusted(String host, int port, KeyStore keyStore) throws GeneralSecurityException, IOException
host
- host to verify for trustport
- host portkeyStore
- key store used to establish trusttrue
if trustedGeneralSecurityException
- certificate exceptionIOException
- I/O exceptionpublic static int trustHost(String url, KeyStore keyStore) throws GeneralSecurityException, IOException
url
- url from which to get the hostkeyStore
- key store used for trust verification and to store
new certificatesGeneralSecurityException
- certificate exceptionIOException
- I/O exceptionpublic static int trustHost(String host, int port, KeyStore keyStore) throws GeneralSecurityException, IOException
host
- the host to trustport
- the host portkeyStore
- key store used for trust verification and to store
new certificatesGeneralSecurityException
- certificate exceptionIOException
- I/O exceptionpublic static String toString(List<X509Certificate> certificates) throws GeneralSecurityException
certificates
- certificates to convert to stringGeneralSecurityException
- certificate exceptionCopyright © 2008–2023 Norconex Inc.. All rights reserved.