code: public static byte[] getEncodedInternal(Certificate cert)
              throws CertificateEncodingException {
          if (cert instanceof X509CertImpl) {
              return ((X509CertImpl)cert).getEncodedInternal();
          } else {
              return cert.getEncoded();
          }
      }
docs: Returned the encoding of the given certificate for internal use.
  Callers must guarantee that they neither modify it nor expose it
  to untrusted code. Uses getEncodedInternal() if the certificate
  is instance of X509CertImpl, getEncoded() otherwise.