public static SelfSignedP12Certificate create() {
    try {
      final KeyPair keyPair = generateKeyPair();
      final Certificate certificate = generateSelfSignedCertificate(keyPair);
      final Path keyStore = createKeyStore(keyPair.getPrivate(), certificate);
      final Path trustStore = createTrustStore(certificate);
      return new SelfSignedP12Certificate(certificate, keyStore, trustStore);
    } catch (final IOException | GeneralSecurityException | OperatorCreationException e) {
      throw new RuntimeException("Error creating self signed certificates", e);
    }
  }
Utility class to generate temporary self-signed certificates in PKCS12 format for testing
purposes using BouncyCastle APIs. The generated certificate supports SAN extension for multiple
DNS and IP addresses

<p>Note: DO NOT USE IN PRODUCTION. The generated stores and files are marked to be deleted on JVM
exit.
ethereum/api/src/test-support/java/org/hyperledger/besu/ethereum/api/tls/SelfSignedP12Certificate.java