Module bus.http

Class Handshake

java.lang.Object
org.miaixz.bus.http.socket.Handshake

public final class Handshake extends Object
A record of a TLS handshake. This class holds information about the TLS version, cipher suite, and the certificates of both the peer and the local party for an HTTPS connection.
Since:
Java 17+
Author:
Kimi Liu
  • Method Details

    • get

      public static Handshake get(SSLSession session) throws IOException
      Creates a Handshake instance from an SSL session.
      Parameters:
      session - The SSL session.
      Returns:
      A new Handshake instance.
      Throws:
      IOException - if the session is invalid or parsing fails.
    • get

      public static Handshake get(org.miaixz.bus.core.net.tls.TlsVersion tlsVersion, CipherSuite cipherSuite, List<Certificate> peerCertificates, List<Certificate> localCertificates)
      Creates a Handshake instance from its components.
      Parameters:
      tlsVersion - The TLS version.
      cipherSuite - The cipher suite.
      peerCertificates - The list of peer certificates.
      localCertificates - The list of local certificates.
      Returns:
      A new Handshake instance.
      Throws:
      NullPointerException - if tlsVersion or cipherSuite is null.
    • tlsVersion

      public org.miaixz.bus.core.net.tls.TlsVersion tlsVersion()
      Returns the TLS version of the connection.
      Returns:
      The TlsVersion.
    • cipherSuite

      public CipherSuite cipherSuite()
      Returns the cipher suite of the connection.
      Returns:
      The CipherSuite.
    • peerCertificates

      public List<Certificate> peerCertificates()
      Returns a list of certificates that identify the remote peer.
      Returns:
      An immutable list of certificates, which may be empty.
    • peerPrincipal

      public Principal peerPrincipal()
      Returns the principal that identifies the remote peer.
      Returns:
      The peer's principal, or null if the peer is anonymous.
    • localCertificates

      public List<Certificate> localCertificates()
      Returns a list of certificates that identify this side of the connection.
      Returns:
      An immutable list of certificates, which may be empty.
    • localPrincipal

      public Principal localPrincipal()
      Returns the principal that identifies this side of the connection.
      Returns:
      The local principal, or null if this side is anonymous.
    • equals

      public boolean equals(Object other)
      Compares this Handshake object with another for equality.
      Overrides:
      equals in class Object
      Parameters:
      other - The other object to compare against.
      Returns:
      true if the two Handshake objects are equal.
    • hashCode

      public int hashCode()
      Computes the hash code for this Handshake object.
      Overrides:
      hashCode in class Object
      Returns:
      The hash code value.
    • toString

      public String toString()
      Returns a string representation of this Handshake.
      Overrides:
      toString in class Object
      Returns:
      A string containing TLS version, cipher suite, and certificate information.