HttpsURLConnection (Java Platform SE 7 ) (original) (raw)
- java.net.URLConnection
- java.net.HttpURLConnection
- javax.net.ssl.HttpsURLConnection
- java.net.HttpURLConnection
public abstract class HttpsURLConnection
extends HttpURLConnectionHttpsURLConnection
extends HttpURLConnection
with support for https-specific features.
See http://www.w3.org/pub/WWW/Protocols/ and RFC 2818 for more details on the https specification.
This class uses HostnameVerifier
andSSLSocketFactory
. There are default implementations defined for both classes. However, the implementations can be replaced on a per-class (static) or per-instance basis. All new HttpsURLConnection
s instances will be assigned the "default" static values at instance creation, but they can be overriden by calling the appropriate per-instance set method(s) beforeconnect
ing.
Since:
1.4
Field Summary
Fields
Modifier and Type Field and Description protected HostnameVerifier hostnameVerifier The hostnameVerifier for this object. * ### Fields inherited from class java.net.[HttpURLConnection](../../../java/net/HttpURLConnection.html "class in java.net") `[chunkLength](../../../java/net/HttpURLConnection.html#chunkLength), [fixedContentLength](../../../java/net/HttpURLConnection.html#fixedContentLength), [fixedContentLengthLong](../../../java/net/HttpURLConnection.html#fixedContentLengthLong), [HTTP_ACCEPTED](../../../java/net/HttpURLConnection.html#HTTP%5FACCEPTED), [HTTP_BAD_GATEWAY](../../../java/net/HttpURLConnection.html#HTTP%5FBAD%5FGATEWAY), [HTTP_BAD_METHOD](../../../java/net/HttpURLConnection.html#HTTP%5FBAD%5FMETHOD), [HTTP_BAD_REQUEST](../../../java/net/HttpURLConnection.html#HTTP%5FBAD%5FREQUEST), [HTTP_CLIENT_TIMEOUT](../../../java/net/HttpURLConnection.html#HTTP%5FCLIENT%5FTIMEOUT), [HTTP_CONFLICT](../../../java/net/HttpURLConnection.html#HTTP%5FCONFLICT), [HTTP_CREATED](../../../java/net/HttpURLConnection.html#HTTP%5FCREATED), [HTTP_ENTITY_TOO_LARGE](../../../java/net/HttpURLConnection.html#HTTP%5FENTITY%5FTOO%5FLARGE), [HTTP_FORBIDDEN](../../../java/net/HttpURLConnection.html#HTTP%5FFORBIDDEN), [HTTP_GATEWAY_TIMEOUT](../../../java/net/HttpURLConnection.html#HTTP%5FGATEWAY%5FTIMEOUT), [HTTP_GONE](../../../java/net/HttpURLConnection.html#HTTP%5FGONE), [HTTP_INTERNAL_ERROR](../../../java/net/HttpURLConnection.html#HTTP%5FINTERNAL%5FERROR), [HTTP_LENGTH_REQUIRED](../../../java/net/HttpURLConnection.html#HTTP%5FLENGTH%5FREQUIRED), [HTTP_MOVED_PERM](../../../java/net/HttpURLConnection.html#HTTP%5FMOVED%5FPERM), [HTTP_MOVED_TEMP](../../../java/net/HttpURLConnection.html#HTTP%5FMOVED%5FTEMP), [HTTP_MULT_CHOICE](../../../java/net/HttpURLConnection.html#HTTP%5FMULT%5FCHOICE), [HTTP_NO_CONTENT](../../../java/net/HttpURLConnection.html#HTTP%5FNO%5FCONTENT), [HTTP_NOT_ACCEPTABLE](../../../java/net/HttpURLConnection.html#HTTP%5FNOT%5FACCEPTABLE), [HTTP_NOT_AUTHORITATIVE](../../../java/net/HttpURLConnection.html#HTTP%5FNOT%5FAUTHORITATIVE), [HTTP_NOT_FOUND](../../../java/net/HttpURLConnection.html#HTTP%5FNOT%5FFOUND), [HTTP_NOT_IMPLEMENTED](../../../java/net/HttpURLConnection.html#HTTP%5FNOT%5FIMPLEMENTED), [HTTP_NOT_MODIFIED](../../../java/net/HttpURLConnection.html#HTTP%5FNOT%5FMODIFIED), [HTTP_OK](../../../java/net/HttpURLConnection.html#HTTP%5FOK), [HTTP_PARTIAL](../../../java/net/HttpURLConnection.html#HTTP%5FPARTIAL), [HTTP_PAYMENT_REQUIRED](../../../java/net/HttpURLConnection.html#HTTP%5FPAYMENT%5FREQUIRED), [HTTP_PRECON_FAILED](../../../java/net/HttpURLConnection.html#HTTP%5FPRECON%5FFAILED), [HTTP_PROXY_AUTH](../../../java/net/HttpURLConnection.html#HTTP%5FPROXY%5FAUTH), [HTTP_REQ_TOO_LONG](../../../java/net/HttpURLConnection.html#HTTP%5FREQ%5FTOO%5FLONG), [HTTP_RESET](../../../java/net/HttpURLConnection.html#HTTP%5FRESET), [HTTP_SEE_OTHER](../../../java/net/HttpURLConnection.html#HTTP%5FSEE%5FOTHER), [HTTP_SERVER_ERROR](../../../java/net/HttpURLConnection.html#HTTP%5FSERVER%5FERROR), [HTTP_UNAUTHORIZED](../../../java/net/HttpURLConnection.html#HTTP%5FUNAUTHORIZED), [HTTP_UNAVAILABLE](../../../java/net/HttpURLConnection.html#HTTP%5FUNAVAILABLE), [HTTP_UNSUPPORTED_TYPE](../../../java/net/HttpURLConnection.html#HTTP%5FUNSUPPORTED%5FTYPE), [HTTP_USE_PROXY](../../../java/net/HttpURLConnection.html#HTTP%5FUSE%5FPROXY), [HTTP_VERSION](../../../java/net/HttpURLConnection.html#HTTP%5FVERSION), [instanceFollowRedirects](../../../java/net/HttpURLConnection.html#instanceFollowRedirects), [method](../../../java/net/HttpURLConnection.html#method), [responseCode](../../../java/net/HttpURLConnection.html#responseCode), [responseMessage](../../../java/net/HttpURLConnection.html#responseMessage)` * ### Fields inherited from class java.net.[URLConnection](../../../java/net/URLConnection.html "class in java.net") `[allowUserInteraction](../../../java/net/URLConnection.html#allowUserInteraction), [connected](../../../java/net/URLConnection.html#connected), [doInput](../../../java/net/URLConnection.html#doInput), [doOutput](../../../java/net/URLConnection.html#doOutput), [ifModifiedSince](../../../java/net/URLConnection.html#ifModifiedSince), [url](../../../java/net/URLConnection.html#url), [useCaches](../../../java/net/URLConnection.html#useCaches)`
Constructor Summary
Constructors
Modifier Constructor and Description protected HttpsURLConnection(URL url) Creates an HttpsURLConnection using the URL specified. Method Summary
Methods
Modifier and Type Method and Description abstract String getCipherSuite() Returns the cipher suite in use on this connection. static HostnameVerifier getDefaultHostnameVerifier() Gets the default HostnameVerifier that is inherited by new instances of this class. static SSLSocketFactory getDefaultSSLSocketFactory() Gets the default static SSLSocketFactory that is inherited by new instances of this class. HostnameVerifier getHostnameVerifier() Gets the HostnameVerifier in place on this instance. abstract Certificate[] getLocalCertificates() Returns the certificate(s) that were sent to the server during handshaking. Principal getLocalPrincipal() Returns the principal that was sent to the server during handshaking. Principal getPeerPrincipal() Returns the server's principal which was established as part of defining the session. abstract Certificate[] getServerCertificates() Returns the server's certificate chain which was established as part of defining the session. SSLSocketFactory getSSLSocketFactory() Gets the SSL socket factory to be used when creating sockets for secure https URL connections. static void setDefaultHostnameVerifier(HostnameVerifier v) Sets the default HostnameVerifier inherited by a new instance of this class. static void setDefaultSSLSocketFactory(SSLSocketFactory sf) Sets the default SSLSocketFactory inherited by new instances of this class. void setHostnameVerifier(HostnameVerifier v) Sets the HostnameVerifier for this instance. void setSSLSocketFactory(SSLSocketFactory sf) Sets the SSLSocketFactory to be used when this instance creates sockets for secure https URL connections. * ### Methods inherited from class java.net.[HttpURLConnection](../../../java/net/HttpURLConnection.html "class in java.net") `[disconnect](../../../java/net/HttpURLConnection.html#disconnect%28%29), [getErrorStream](../../../java/net/HttpURLConnection.html#getErrorStream%28%29), [getFollowRedirects](../../../java/net/HttpURLConnection.html#getFollowRedirects%28%29), [getHeaderField](../../../java/net/HttpURLConnection.html#getHeaderField%28int%29), [getHeaderFieldDate](../../../java/net/HttpURLConnection.html#getHeaderFieldDate%28java.lang.String,%20long%29), [getHeaderFieldKey](../../../java/net/HttpURLConnection.html#getHeaderFieldKey%28int%29), [getInstanceFollowRedirects](../../../java/net/HttpURLConnection.html#getInstanceFollowRedirects%28%29), [getPermission](../../../java/net/HttpURLConnection.html#getPermission%28%29), [getRequestMethod](../../../java/net/HttpURLConnection.html#getRequestMethod%28%29), [getResponseCode](../../../java/net/HttpURLConnection.html#getResponseCode%28%29), [getResponseMessage](../../../java/net/HttpURLConnection.html#getResponseMessage%28%29), [setChunkedStreamingMode](../../../java/net/HttpURLConnection.html#setChunkedStreamingMode%28int%29), [setFixedLengthStreamingMode](../../../java/net/HttpURLConnection.html#setFixedLengthStreamingMode%28int%29), [setFixedLengthStreamingMode](../../../java/net/HttpURLConnection.html#setFixedLengthStreamingMode%28long%29), [setFollowRedirects](../../../java/net/HttpURLConnection.html#setFollowRedirects%28boolean%29), [setInstanceFollowRedirects](../../../java/net/HttpURLConnection.html#setInstanceFollowRedirects%28boolean%29), [setRequestMethod](../../../java/net/HttpURLConnection.html#setRequestMethod%28java.lang.String%29), [usingProxy](../../../java/net/HttpURLConnection.html#usingProxy%28%29)` * ### Methods inherited from class java.net.[URLConnection](../../../java/net/URLConnection.html "class in java.net") `[addRequestProperty](../../../java/net/URLConnection.html#addRequestProperty%28java.lang.String,%20java.lang.String%29), [connect](../../../java/net/URLConnection.html#connect%28%29), [getAllowUserInteraction](../../../java/net/URLConnection.html#getAllowUserInteraction%28%29), [getConnectTimeout](../../../java/net/URLConnection.html#getConnectTimeout%28%29), [getContent](../../../java/net/URLConnection.html#getContent%28%29), [getContent](../../../java/net/URLConnection.html#getContent%28java.lang.Class[]%29), [getContentEncoding](../../../java/net/URLConnection.html#getContentEncoding%28%29), [getContentLength](../../../java/net/URLConnection.html#getContentLength%28%29), [getContentLengthLong](../../../java/net/URLConnection.html#getContentLengthLong%28%29), [getContentType](../../../java/net/URLConnection.html#getContentType%28%29), [getDate](../../../java/net/URLConnection.html#getDate%28%29), [getDefaultAllowUserInteraction](../../../java/net/URLConnection.html#getDefaultAllowUserInteraction%28%29), [getDefaultRequestProperty](../../../java/net/URLConnection.html#getDefaultRequestProperty%28java.lang.String%29), [getDefaultUseCaches](../../../java/net/URLConnection.html#getDefaultUseCaches%28%29), [getDoInput](../../../java/net/URLConnection.html#getDoInput%28%29), [getDoOutput](../../../java/net/URLConnection.html#getDoOutput%28%29), [getExpiration](../../../java/net/URLConnection.html#getExpiration%28%29), [getFileNameMap](../../../java/net/URLConnection.html#getFileNameMap%28%29), [getHeaderField](../../../java/net/URLConnection.html#getHeaderField%28java.lang.String%29), [getHeaderFieldInt](../../../java/net/URLConnection.html#getHeaderFieldInt%28java.lang.String,%20int%29), [getHeaderFieldLong](../../../java/net/URLConnection.html#getHeaderFieldLong%28java.lang.String,%20long%29), [getHeaderFields](../../../java/net/URLConnection.html#getHeaderFields%28%29), [getIfModifiedSince](../../../java/net/URLConnection.html#getIfModifiedSince%28%29), [getInputStream](../../../java/net/URLConnection.html#getInputStream%28%29), [getLastModified](../../../java/net/URLConnection.html#getLastModified%28%29), [getOutputStream](../../../java/net/URLConnection.html#getOutputStream%28%29), [getReadTimeout](../../../java/net/URLConnection.html#getReadTimeout%28%29), [getRequestProperties](../../../java/net/URLConnection.html#getRequestProperties%28%29), [getRequestProperty](../../../java/net/URLConnection.html#getRequestProperty%28java.lang.String%29), [getURL](../../../java/net/URLConnection.html#getURL%28%29), [getUseCaches](../../../java/net/URLConnection.html#getUseCaches%28%29), [guessContentTypeFromName](../../../java/net/URLConnection.html#guessContentTypeFromName%28java.lang.String%29), [guessContentTypeFromStream](../../../java/net/URLConnection.html#guessContentTypeFromStream%28java.io.InputStream%29), [setAllowUserInteraction](../../../java/net/URLConnection.html#setAllowUserInteraction%28boolean%29), [setConnectTimeout](../../../java/net/URLConnection.html#setConnectTimeout%28int%29), [setContentHandlerFactory](../../../java/net/URLConnection.html#setContentHandlerFactory%28java.net.ContentHandlerFactory%29), [setDefaultAllowUserInteraction](../../../java/net/URLConnection.html#setDefaultAllowUserInteraction%28boolean%29), [setDefaultRequestProperty](../../../java/net/URLConnection.html#setDefaultRequestProperty%28java.lang.String,%20java.lang.String%29), [setDefaultUseCaches](../../../java/net/URLConnection.html#setDefaultUseCaches%28boolean%29), [setDoInput](../../../java/net/URLConnection.html#setDoInput%28boolean%29), [setDoOutput](../../../java/net/URLConnection.html#setDoOutput%28boolean%29), [setFileNameMap](../../../java/net/URLConnection.html#setFileNameMap%28java.net.FileNameMap%29), [setIfModifiedSince](../../../java/net/URLConnection.html#setIfModifiedSince%28long%29), [setReadTimeout](../../../java/net/URLConnection.html#setReadTimeout%28int%29), [setRequestProperty](../../../java/net/URLConnection.html#setRequestProperty%28java.lang.String,%20java.lang.String%29), [setUseCaches](../../../java/net/URLConnection.html#setUseCaches%28boolean%29), [toString](../../../java/net/URLConnection.html#toString%28%29)` * ### Methods inherited from class java.lang.[Object](../../../java/lang/Object.html "class in java.lang") `[clone](../../../java/lang/Object.html#clone%28%29), [equals](../../../java/lang/Object.html#equals%28java.lang.Object%29), [finalize](../../../java/lang/Object.html#finalize%28%29), [getClass](../../../java/lang/Object.html#getClass%28%29), [hashCode](../../../java/lang/Object.html#hashCode%28%29), [notify](../../../java/lang/Object.html#notify%28%29), [notifyAll](../../../java/lang/Object.html#notifyAll%28%29), [wait](../../../java/lang/Object.html#wait%28%29), [wait](../../../java/lang/Object.html#wait%28long%29), [wait](../../../java/lang/Object.html#wait%28long,%20int%29)`
Field Detail
* #### hostnameVerifier protected [HostnameVerifier](../../../javax/net/ssl/HostnameVerifier.html "interface in javax.net.ssl") hostnameVerifier The `hostnameVerifier` for this object.
Constructor Detail
* #### HttpsURLConnection protected HttpsURLConnection([URL](../../../java/net/URL.html "class in java.net") url) Creates an `HttpsURLConnection` using the URL specified. Parameters: `url` \- the URL
Method Detail
* #### getCipherSuite public abstract [String](../../../java/lang/String.html "class in java.lang") getCipherSuite() Returns the cipher suite in use on this connection. Returns: the cipher suite Throws: `[IllegalStateException](../../../java/lang/IllegalStateException.html "class in java.lang")` \- if this method is called before the connection has been established. * #### getLocalCertificates public abstract [Certificate](../../../java/security/cert/Certificate.html "class in java.security.cert")[] getLocalCertificates() Returns the certificate(s) that were sent to the server during handshaking. Note: This method is useful only when using certificate-based cipher suites. When multiple certificates are available for use in a handshake, the implementation chooses what it considers the "best" certificate chain available, and transmits that to the other side. This method allows the caller to know which certificate chain was actually sent. Returns: an ordered array of certificates, with the client's own certificate first followed by any certificate authorities. If no certificates were sent, then null is returned. Throws: `[IllegalStateException](../../../java/lang/IllegalStateException.html "class in java.lang")` \- if this method is called before the connection has been established. See Also: [getLocalPrincipal()](../../../javax/net/ssl/HttpsURLConnection.html#getLocalPrincipal%28%29) * #### getServerCertificates public abstract [Certificate](../../../java/security/cert/Certificate.html "class in java.security.cert")[] getServerCertificates() throws [SSLPeerUnverifiedException](../../../javax/net/ssl/SSLPeerUnverifiedException.html "class in javax.net.ssl") Returns the server's certificate chain which was established as part of defining the session. Note: This method can be used only when using certificate-based cipher suites; using it with non-certificate-based cipher suites, such as Kerberos, will throw an SSLPeerUnverifiedException. Returns: an ordered array of server certificates, with the peer's own certificate first followed by any certificate authorities. Throws: `[SSLPeerUnverifiedException](../../../javax/net/ssl/SSLPeerUnverifiedException.html "class in javax.net.ssl")` \- if the peer is not verified. `[IllegalStateException](../../../java/lang/IllegalStateException.html "class in java.lang")` \- if this method is called before the connection has been established. See Also: [getPeerPrincipal()](../../../javax/net/ssl/HttpsURLConnection.html#getPeerPrincipal%28%29) * #### getPeerPrincipal public [Principal](../../../java/security/Principal.html "interface in java.security") getPeerPrincipal() throws [SSLPeerUnverifiedException](../../../javax/net/ssl/SSLPeerUnverifiedException.html "class in javax.net.ssl") Returns the server's principal which was established as part of defining the session. Note: Subclasses should override this method. If not overridden, it will default to returning the X500Principal of the server's end-entity certificate for certificate-based ciphersuites, or throw an SSLPeerUnverifiedException for non-certificate based ciphersuites, such as Kerberos. Returns: the server's principal. Returns an X500Principal of the end-entity certiticate for X509-based cipher suites, and KerberosPrincipal for Kerberos cipher suites. Throws: `[SSLPeerUnverifiedException](../../../javax/net/ssl/SSLPeerUnverifiedException.html "class in javax.net.ssl")` \- if the peer was not verified `[IllegalStateException](../../../java/lang/IllegalStateException.html "class in java.lang")` \- if this method is called before the connection has been established. Since: 1.5 See Also: [getServerCertificates()](../../../javax/net/ssl/HttpsURLConnection.html#getServerCertificates%28%29), [getLocalPrincipal()](../../../javax/net/ssl/HttpsURLConnection.html#getLocalPrincipal%28%29) * #### getLocalPrincipal public [Principal](../../../java/security/Principal.html "interface in java.security") getLocalPrincipal() Returns the principal that was sent to the server during handshaking. Note: Subclasses should override this method. If not overridden, it will default to returning the X500Principal of the end-entity certificate that was sent to the server for certificate-based ciphersuites or, return null for non-certificate based ciphersuites, such as Kerberos. Returns: the principal sent to the server. Returns an X500Principal of the end-entity certificate for X509-based cipher suites, and KerberosPrincipal for Kerberos cipher suites. If no principal was sent, then null is returned. Throws: `[IllegalStateException](../../../java/lang/IllegalStateException.html "class in java.lang")` \- if this method is called before the connection has been established. Since: 1.5 See Also: [getLocalCertificates()](../../../javax/net/ssl/HttpsURLConnection.html#getLocalCertificates%28%29), [getPeerPrincipal()](../../../javax/net/ssl/HttpsURLConnection.html#getPeerPrincipal%28%29) * #### setDefaultHostnameVerifier public static void setDefaultHostnameVerifier([HostnameVerifier](../../../javax/net/ssl/HostnameVerifier.html "interface in javax.net.ssl") v) Sets the default `HostnameVerifier` inherited by a new instance of this class. If this method is not called, the default`HostnameVerifier` assumes the connection should not be permitted. Parameters: `v` \- the default host name verifier Throws: `[IllegalArgumentException](../../../java/lang/IllegalArgumentException.html "class in java.lang")` \- if the `HostnameVerifier` parameter is null. `[SecurityException](../../../java/lang/SecurityException.html "class in java.lang")` \- if a security manager exists and its`checkPermission` method does not allow`SSLPermission("setHostnameVerifier")` See Also: [getDefaultHostnameVerifier()](../../../javax/net/ssl/HttpsURLConnection.html#getDefaultHostnameVerifier%28%29) * #### getDefaultHostnameVerifier public static [HostnameVerifier](../../../javax/net/ssl/HostnameVerifier.html "interface in javax.net.ssl") getDefaultHostnameVerifier() Gets the default `HostnameVerifier` that is inherited by new instances of this class. Returns: the default host name verifier See Also: [setDefaultHostnameVerifier(HostnameVerifier)](../../../javax/net/ssl/HttpsURLConnection.html#setDefaultHostnameVerifier%28javax.net.ssl.HostnameVerifier%29) * #### setHostnameVerifier public void setHostnameVerifier([HostnameVerifier](../../../javax/net/ssl/HostnameVerifier.html "interface in javax.net.ssl") v) Sets the `HostnameVerifier` for this instance. New instances of this class inherit the default static hostname verifier set by [setDefaultHostnameVerifier](../../../javax/net/ssl/HttpsURLConnection.html#setDefaultHostnameVerifier%28javax.net.ssl.HostnameVerifier%29). Calls to this method replace this object's `HostnameVerifier`. Parameters: `v` \- the host name verifier Throws: `[IllegalArgumentException](../../../java/lang/IllegalArgumentException.html "class in java.lang")` \- if the `HostnameVerifier` parameter is null. See Also: [getHostnameVerifier()](../../../javax/net/ssl/HttpsURLConnection.html#getHostnameVerifier%28%29), [setDefaultHostnameVerifier(HostnameVerifier)](../../../javax/net/ssl/HttpsURLConnection.html#setDefaultHostnameVerifier%28javax.net.ssl.HostnameVerifier%29) * #### getHostnameVerifier public [HostnameVerifier](../../../javax/net/ssl/HostnameVerifier.html "interface in javax.net.ssl") getHostnameVerifier() Gets the `HostnameVerifier` in place on this instance. Returns: the host name verifier See Also: [setHostnameVerifier(HostnameVerifier)](../../../javax/net/ssl/HttpsURLConnection.html#setHostnameVerifier%28javax.net.ssl.HostnameVerifier%29), [setDefaultHostnameVerifier(HostnameVerifier)](../../../javax/net/ssl/HttpsURLConnection.html#setDefaultHostnameVerifier%28javax.net.ssl.HostnameVerifier%29) * #### setDefaultSSLSocketFactory public static void setDefaultSSLSocketFactory([SSLSocketFactory](../../../javax/net/ssl/SSLSocketFactory.html "class in javax.net.ssl") sf) Sets the default `SSLSocketFactory` inherited by new instances of this class. The socket factories are used when creating sockets for secure https URL connections. Parameters: `sf` \- the default SSL socket factory Throws: `[IllegalArgumentException](../../../java/lang/IllegalArgumentException.html "class in java.lang")` \- if the SSLSocketFactory parameter is null. `[SecurityException](../../../java/lang/SecurityException.html "class in java.lang")` \- if a security manager exists and its`checkSetFactory` method does not allow a socket factory to be specified. See Also: [getDefaultSSLSocketFactory()](../../../javax/net/ssl/HttpsURLConnection.html#getDefaultSSLSocketFactory%28%29) * #### getDefaultSSLSocketFactory public static [SSLSocketFactory](../../../javax/net/ssl/SSLSocketFactory.html "class in javax.net.ssl") getDefaultSSLSocketFactory() Gets the default static `SSLSocketFactory` that is inherited by new instances of this class. The socket factories are used when creating sockets for secure https URL connections. Returns: the default `SSLSocketFactory` See Also: [setDefaultSSLSocketFactory(SSLSocketFactory)](../../../javax/net/ssl/HttpsURLConnection.html#setDefaultSSLSocketFactory%28javax.net.ssl.SSLSocketFactory%29) * #### setSSLSocketFactory public void setSSLSocketFactory([SSLSocketFactory](../../../javax/net/ssl/SSLSocketFactory.html "class in javax.net.ssl") sf) Sets the `SSLSocketFactory` to be used when this instance creates sockets for secure https URL connections. New instances of this class inherit the default static`SSLSocketFactory` set by[setDefaultSSLSocketFactory](../../../javax/net/ssl/HttpsURLConnection.html#setDefaultSSLSocketFactory%28javax.net.ssl.SSLSocketFactory%29). Calls to this method replace this object's `SSLSocketFactory`. Parameters: `sf` \- the SSL socket factory Throws: `[IllegalArgumentException](../../../java/lang/IllegalArgumentException.html "class in java.lang")` \- if the `SSLSocketFactory` parameter is null. See Also: [getSSLSocketFactory()](../../../javax/net/ssl/HttpsURLConnection.html#getSSLSocketFactory%28%29) * #### getSSLSocketFactory public [SSLSocketFactory](../../../javax/net/ssl/SSLSocketFactory.html "class in javax.net.ssl") getSSLSocketFactory() Gets the SSL socket factory to be used when creating sockets for secure https URL connections. Returns: the `SSLSocketFactory` See Also: [setSSLSocketFactory(SSLSocketFactory)](../../../javax/net/ssl/HttpsURLConnection.html#setSSLSocketFactory%28javax.net.ssl.SSLSocketFactory%29)
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2020, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.