javax.net.ssl

Class HttpsURLConnection


  • public abstract class HttpsURLConnection
    extends HttpURLConnection
    HttpsURLConnection 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 and SSLSocketFactory. 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 HttpsURLConnections 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) before connecting.

    Since:
    1.4
    • Field Detail

      • hostnameVerifier

        protected HostnameVerifier hostnameVerifier
        The hostnameVerifier for this object.
    • Constructor Detail

      • HttpsURLConnection

        protected HttpsURLConnection(URL url)
        Creates an HttpsURLConnection using the URL specified.
        Parameters:
        url - the URL
    • Method Detail

      • getCipherSuite

        public abstract String getCipherSuite()
        Returns the cipher suite in use on this connection.
        Returns:
        the cipher suite
        Throws:
        IllegalStateException - if this method is called before the connection has been established.
      • getLocalCertificates

        public abstract Certificate[] 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 - if this method is called before the connection has been established.
        See Also:
        getLocalPrincipal()
      • getServerCertificates

        public abstract Certificate[] getServerCertificates()
                                                     throws SSLPeerUnverifiedException
        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 - if the peer is not verified.
        IllegalStateException - if this method is called before the connection has been established.
        See Also:
        getPeerPrincipal()
      • getPeerPrincipal

        public Principal getPeerPrincipal()
                                   throws SSLPeerUnverifiedException
        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 - if the peer was not verified
        IllegalStateException - if this method is called before the connection has been established.
        Since:
        1.5
        See Also:
        getServerCertificates(), getLocalPrincipal()
      • getLocalPrincipal

        public Principal 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 - if this method is called before the connection has been established.
        Since:
        1.5
        See Also:
        getLocalCertificates(), getPeerPrincipal()
      • setDefaultHostnameVerifier

        public static void setDefaultHostnameVerifier(HostnameVerifier 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 - if the HostnameVerifier parameter is null.
        SecurityException - if a security manager exists and its checkPermission method does not allow SSLPermission("setHostnameVerifier")
        See Also:
        getDefaultHostnameVerifier()
      • setDefaultSSLSocketFactory

        public static void setDefaultSSLSocketFactory(SSLSocketFactory 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 - if the SSLSocketFactory parameter is null.
        SecurityException - if a security manager exists and its checkSetFactory method does not allow a socket factory to be specified.
        See Also:
        getDefaultSSLSocketFactory()
      • getDefaultSSLSocketFactory

        public static SSLSocketFactory 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)
      • setSSLSocketFactory

        public void setSSLSocketFactory(SSLSocketFactory 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. Calls to this method replace this object's SSLSocketFactory.

        Parameters:
        sf - the SSL socket factory
        Throws:
        IllegalArgumentException - if the SSLSocketFactory parameter is null.
        See Also:
        getSSLSocketFactory()

Deutsche Übersetzung

Sie haben gebeten, diese Seite auf Deutsch zu besuchen. Momentan ist nur die Oberfläche übersetzt, aber noch nicht der gesamte Inhalt.

Wenn Sie mir bei Übersetzungen helfen wollen, ist Ihr Beitrag willkommen. Alles, was Sie tun müssen, ist, sich auf der Website zu registrieren und mir eine Nachricht zu schicken, in der Sie gebeten werden, Sie der Gruppe der Übersetzer hinzuzufügen, die Ihnen die Möglichkeit gibt, die gewünschten Seiten zu übersetzen. Ein Link am Ende jeder übersetzten Seite zeigt an, dass Sie der Übersetzer sind und einen Link zu Ihrem Profil haben.

Vielen Dank im Voraus.

Dokument erstellt 11/06/2005, zuletzt geändert 04/03/2020
Quelle des gedruckten Dokuments:https://www.gaudry.be/de/java-api-rf-javax/net/ssl/httpsurlconnection.html

Die Infobro ist eine persönliche Seite, deren Inhalt in meiner alleinigen Verantwortung liegt. Der Text ist unter der CreativeCommons-Lizenz (BY-NC-SA) verfügbar. Weitere Informationen auf die Nutzungsbedingungen und dem Autor.

Referenzen

  1. Zeigen Sie - html-Dokument Sprache des Dokuments:fr Manuel PHP : https://docs.oracle.com

Diese Verweise und Links verweisen auf Dokumente, die während des Schreibens dieser Seite konsultiert wurden, oder die zusätzliche Informationen liefern können, aber die Autoren dieser Quellen können nicht für den Inhalt dieser Seite verantwortlich gemacht werden.
Der Autor Diese Website ist allein dafür verantwortlich, wie die verschiedenen Konzepte und Freiheiten, die mit den Nachschlagewerken gemacht werden, hier dargestellt werden. Denken Sie daran, dass Sie mehrere Quellinformationen austauschen müssen, um das Risiko von Fehlern zu reduzieren.

Inhaltsverzeichnis Haut