Interface SelfSignedCertificate


public interface SelfSignedCertificate
Provides access to self-signed certificate artifacts generated for SSL/TLS testing.

When a test class is annotated with @SelfSignedCert, the extension generates self-signed certificates for both server and client. This type can be injected into test fields annotated with @SslCert or into test method parameters by type.

Usage

@SelfSignedCert
@RestBootstrap(MyResource.class)
public class SslTest {

    @SslCert
    private SelfSignedCertificate certificate;

    @Test
    public void testSsl() {
        SSLContext clientCtx = certificate.clientSslContext();
        // use the client SSL context to configure a non-Jakarta REST client
    }
}

When combined with @RestBootstrap, the server is automatically started with HTTPS and injected Client instances are configured with the client SSLContext. In that case, direct access to this type is often not needed.

This type is primarily useful when configuring non-Jakarta REST HTTP clients, when direct access to keystore files is required, or when using @SelfSignedCert standalone without @RestBootstrap.

For custom SSL configuration (e.g., using your own certificates), use a ConfigurationProvider for the server and a RestClientBuilderProvider for the client instead.

Since:
1.0
Author:
James R. Perkins
See Also:
  • Method Details

    • clientSslContext

      SSLContext clientSslContext()
      Returns the SSLContext configured for the client.

      This context is automatically applied to injected Client instances when @SelfSignedCert is present on the test class alongside @RestBootstrap and no custom RestClientBuilderProvider is specified via @RestClientConfig. When a custom provider is used, it is responsible for configuring the client SSL context itself, typically via @SslCert field injection.

      Returns:
      the client SSL context
    • clientKeyStore

      KeyStore clientKeyStore()
      Returns the client KeyStore containing the client's private key and certificate.

      This can be used directly with APIs that accept a KeyStore, such as ClientBuilder.keyStore().

      Returns:
      the client keystore
    • clientKeyStorePath

      Path clientKeyStorePath()
      Returns the path to the client keystore file containing the client's private key and certificate.
      Returns:
      the path to the client keystore file
    • clientTrustStore

      KeyStore clientTrustStore()
      Returns the client truststore containing the server's certificate.

      This can be used directly with APIs that accept a KeyStore, such as ClientBuilder.trustStore().

      Returns:
      the client truststore
    • clientTrustStorePath

      Path clientTrustStorePath()
      Returns the path to the client truststore file containing the server's certificate.
      Returns:
      the path to the client truststore file
    • serverSslContext

      SSLContext serverSslContext()
      Returns the SSLContext configured for the server.

      This context is automatically applied to the SeBootstrap Configuration when @SelfSignedCert is present on the test class alongside @RestBootstrap and no custom ConfigurationProvider is specified via configFactory. When a custom provider is used, it is responsible for configuring the server SSL context itself, typically via @SslCert field injection.

      Returns:
      the server SSL context
    • serverKeyStore

      KeyStore serverKeyStore()
      Returns the server KeyStore containing the server's private key and certificate.

      This can be used directly with APIs that accept a KeyStore, such as ClientBuilder.keyStore().

      Returns:
      the server keystore
    • serverKeyStorePath

      Path serverKeyStorePath()
      Returns the path to the server keystore file containing the server's private key and certificate.
      Returns:
      the path to the server keystore file
    • serverTrustStore

      KeyStore serverTrustStore()
      Returns the server truststore containing the client's certificate.

      This can be used directly with APIs that accept a KeyStore, such as ClientBuilder.trustStore().

      Returns:
      the server truststore
    • serverTrustStorePath

      Path serverTrustStorePath()
      Returns the path to the server truststore file containing the client's certificate.
      Returns:
      the path to the server truststore file
    • keyStorePassword

      String keyStorePassword()
      Returns the password used for all keystore and truststore files.
      Returns:
      the keystore password
    • keyStoreType

      String keyStoreType()
      Returns the keystore type used for all generated keystore and truststore files.
      Returns:
      the keystore type (e.g., "PKCS12")