I. Overview
This class is located under the JAVAX.NET.SSL package, class declaration: PublicAbstract classhttpsurlconnection extends HttpURLConnection
Class Hierarchy:
Java.lang.Object java.net.URLConnection java.net.HttpURLConnection Javax.net.ssl.HttpsURLConnection
HttpsURLConnection
Extended HttpURLConnection
to support a variety of HTTPS-specific features.
This class uses
HostnameVerifier
And
SSLSocketFactory
。 The default implementation is defined for each of the two classes. However, you can replace the implementation on a per-class (static) or per-instance basis. All NEW
HttpsURLConnection
Instances are assigned a "default" static value when they are created, by
连接
You can override these values before invoking the appropriate set method for each instance.
Second, the field
Hostnameverifier hostnameVerifier
.
Third, the construction method
httpsurlconnection (URL url) HttpsURLConnection
.
Iv. methods
1.Stringgetciphersuite() returns the cipher suite used on this connection.
thrown:
IllegalStateException
-If this method is called before the connection is established.
2, public abstract certificate[] Getlocalcertificates () returns the certificate sent to the server during the handshake.
Note: This method is only useful if you are using a certificate-based cipher suite.
When multiple certificates are available for use in a single handshake, the implementation chooses what it deems to be the "best" available certificate chain and transmits it to the other party. This method allows the caller to know the actual sent certificate chain.
returns: an ordered array of certificates, followed by all certification authorities, before the client's certificate. If no certificate is sent, NULL is returned.
Thrown:
IllegalStateException
-If this method is called before the connection is established.
3, public abstract certificate[] Getservercertificates () throws Sslpeerunverifiedexception returns the certificate chain of the server, which is established as part of the definition session.
Note: You can use this method only if you are using a certificate-based cipher suite, and using it with a non-certificate-based cipher suite, such as Kerberos, throws Sslpeerunverifiedexception.
returns: an ordered array of server certificates, followed by all certificate authorities, before the certificate for the same bit.
Thrown:
SSLPeerUnverifiedException
-If the same bit is not validated.
IllegalStateException
-If this method is called before the connection is established.
4, Public Principal Getpeerprincipal () throws Sslpeerunverifiedexception returns the principal of the server, which is established as part of the definition session.
Note: Subclasses should override this method. If you do not override this method, for a certificate-based cipher suite, it returns the X500principal of the server Terminal entity certificate by default, and Sslpeerunverifiedexception is thrown for non-certificate-based cipher suites such as Kerberos.
returns: the principal of the server. Returns the X500principal of the terminal entity certificate based on the X509 cipher suite, as well as the kerberosprincipal of the Kerberos cipher suite.
Thrown:
SSLPeerUnverifiedException
-If the same body is not verified
IllegalStateException
-If this method is called before the connection is established.
5.
Public Principal
getlocalprincipal
() returns the principal that is sent to the server during the handshake.
Note: Subclasses should override this method. If this method is not overridden, for a certificate-based cipher suite, it returns the X500principal of the Terminal entity certificate sent to the server by default, or null for non-certificate-based cipher suites such as Kerberos.
returns: the principal that is sent to the server. Returns the X500principal of the terminal entity certificate based on the X509 cipher suite, as well as the kerberosprincipal of the Kerberos cipher suite. If no principal is sent, NULL is returned.
Thrown:
IllegalStateException
-If this method is called before the connection is established.
6, public static void Setdefaulthostnameverifier (Hostnameverifier v) sets the default inherited by a new instance of this class
HostnameVerifier
.
If you do not call this method, the default assumption is that the HostnameVerifier
connection should not be allowed.
Parameters:
v
-Default host Elite test device
Thrown:
IllegalArgumentException
-if
HostnameVerifier
the argument is null.
SecurityException
-If the security manager exists and its
checkPermission
methods do not allow
SSLPermission("setHostnameVerifier")
7, public
static hostnameverifier
Getdefaultho Stnameverifier
() gets the default inherited by a new instance of this class
HostnameVerifier
.
8. Public
void
Sethostnameverifier
(hostnameverifier
v) To set this instance
HostnameVerifier
.
A new instance of this class inherits from
setDefaultHostnameVerifier
the default static host set by the elite school inspector. Calling this method replaces the object's
HostnameVerifier
.
Parameters:
v
-Host School test device
Thrown:
IllegalArgumentException
-if
HostnameVerifier
the argument is null.
9, public hostnameverifier
gethostnameverifier() Get this instance appropriate
HostnameVerifier(主机名校验器)
.
10. public static void
setdefaultsslsocketfactory(sslsocketfactory SF) sets the default inherited by a new instance of this class
SSLSocketFactory
.
Socket factory is used when creating sockets for secure HTTPS URL connections.
Parameters:
sf
-Default SSL Socket factory
thrown:
IllegalArgumentException
-If the sslsocketfactory parameter is null.
SecurityException
-If the security manager exists and its
checkSetFactory
methods do not allow the socket factory to be specified.
11, public static sslsocketfactory
getdefaultsslsocketfactory() gets the default static inherited by a new instance of this class
SSLSocketFactory
.
Socket factory is used when creating sockets for secure HTTPS URL connections.
12, public void
setsslsocketfactory(sslsocketfactory SF) is set when this instance is used to create a socket for a secure HTTPS URL connection
SSLSocketFactory
.
A new instance of this class is inherited by
setDefaultSSLSocketFactory
the default static set
SSLSocketFactory
. Calling this method replaces the object's
SSLSocketFactory
.
Parameters:
sf
-SSL Socket Factory
thrown:
IllegalArgumentException
-If
SSLSocketFactory
the parameter is null.
13. Public Sslsocketfactory
getsslsocketfactory() gets the SSL socket factory used when creating sockets for secure HTTPS URL connections.
Httpsurlconnection abstract classes in Java