code: public static CertifiedPublicKey convertCertificate(CertificateFactory certFactory, X509CertificateHolder cert)
      {
          if (cert == null) {
              return null;
          }
  
          if (certFactory instanceof BcX509CertificateFactory) {
              return ((BcX509CertificateFactory) certFactory).convert(cert);
          } else {
              try {
                  return certFactory.decode(cert.getEncoded());
              } catch (IOException e) {
                  // Very unlikely
                  throw new IllegalArgumentException("Invalid Certificate, unable to encode", e);
              }
          }
      }
docs: Convert a Bouncy Castle certificate holder into a certified public key.
  
  @param certFactory the certificate factory to be used for conversion.
  @param cert the certificate to convert.
  @return a certified public key wrapping equivalent to the provided holder.
  @since 6.0M1