Class SelfSignedSslContextSource

java.lang.Object
org.microproxy.tls.SelfSignedSslContextSource
All Implemented Interfaces:
SslContextSource

public class SelfSignedSslContextSource extends Object implements SslContextSource
An SslContextSource backed by a self-signed certificate generated in memory for localhost, 127.0.0.1 and ::1 (or the names given). The same instance can serve both ends of a connection, e.g. an encrypted chained proxy and the proxy it chains to, because its trust store contains its own certificate.
  • Constructor Details

    • SelfSignedSslContextSource

      public SelfSignedSslContextSource()
      Creates a TLS context source with a generated self-signed certificate.
    • SelfSignedSslContextSource

      public SelfSignedSslContextSource(boolean trustAllServers)
      Creates a TLS context source with a generated self-signed certificate.
      Parameters:
      trustAllServers - whether to trust all peer certificates instead of only the generated certificate
    • SelfSignedSslContextSource

      public SelfSignedSslContextSource(boolean trustAllServers, boolean sendCerts, String... names)
      Creates a TLS context source with a generated self-signed certificate.
      Parameters:
      trustAllServers - trust any peer instead of only this certificate
      sendCerts - present the certificate (needed on the server side and for client auth)
      names - the DNS names or IP literals to include in the certificate
  • Method Details

    • getSslContext

      public SSLContext getSslContext()
      Description copied from interface: SslContextSource
      Returns the TLS context for this connection.
      Specified by:
      getSslContext in interface SslContextSource
      Returns:
      the TLS context for this connection
    • getKeyMaterial

      public KeyMaterial getKeyMaterial(String serverName)
      The generated certificate and its key, for the HTTP/3 listener; null when this source does not present its certificate.
      Specified by:
      getKeyMaterial in interface SslContextSource
      Parameters:
      serverName - the server name the client asked for (SNI), or null if it sent none
      Returns:
      the chain and key to present, or null if this source has none
    • getCertificate

      public X509Certificate getCertificate()
      Returns the certificate presented by this source.
      Returns:
      the certificate presented by this source