Record Class KeyMaterial

java.lang.Object
java.lang.Record
org.microproxy.KeyMaterial
Record Components:
chain - the certificate chain, end-entity certificate first, then its issuers; not empty
privateKey - the private key of the end-entity certificate

public record KeyMaterial(List<X509Certificate> chain, PrivateKey privateKey) extends Record
A certificate chain and the private key of its first certificate: what a TLS server presents. Listeners that run a TLS handshake of their own rather than the JDK's, such as the HTTP/3 listener (QUIC carries TLS 1.3 itself), take their certificate in this form, from SslContextSource.getKeyMaterial(String).
  • Constructor Details

    • KeyMaterial

      public KeyMaterial(List<X509Certificate> chain, PrivateKey privateKey)
      Creates key material.
      Parameters:
      chain - the certificate chain, end-entity certificate first; copied
      privateKey - the end-entity certificate's private key
      Throws:
      IllegalArgumentException - if the chain is empty
  • Method Details

    • fromKeyStore

      public static KeyMaterial fromKeyStore(KeyStore keyStore, String alias, char[] password) throws GeneralSecurityException
      The key entry alias of a key store, or its first key entry when alias is null.
      Parameters:
      keyStore - the loaded key store
      alias - the entry's alias, or null for the first key entry
      password - the entry's password
      Returns:
      the entry's chain and private key
      Throws:
      GeneralSecurityException - if the key store has no such key entry, or it cannot be read
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • chain

      public List<X509Certificate> chain()
      Returns the value of the chain record component.
      Returns:
      the value of the chain record component
    • privateKey

      public PrivateKey privateKey()
      Returns the value of the privateKey record component.
      Returns:
      the value of the privateKey record component