code: public static X509CertImpl toImpl(X509Certificate cert)
              throws CertificateException {
          if (cert instanceof X509CertImpl) {
              return (X509CertImpl)cert;
          } else {
              return X509Factory.intern(cert);
          }
      }
docs: Utility method to convert an arbitrary instance of X509Certificate
  to a X509CertImpl. Does a cast if possible, otherwise reparses
  the encoding.