public String getCommonName() {
    try {
      final X500Name subject = new X509CertificateHolder(certificate.getEncoded()).getSubject();
      final RDN commonNameRdn = subject.getRDNs(BCStyle.CN)[0];
      return IETFUtils.valueToString(commonNameRdn.getFirst().getValue());
    } catch (final IOException | CertificateEncodingException e) {
      throw new RuntimeException("Error extracting common name from certificate", 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