code: protected static String openssl_X509_NAME_hash(X500Principal p) throws Exception {
          // This code replicates OpenSSL's hashing function
          // DER-encode the Principal, MD5 hash it, then extract the first 4 bytes and reverse their positions
          byte[] derEncodedSubject = p.getEncoded();
          byte[] md5 = MessageDigest.getInstance("MD5").digest(derEncodedSubject);
  
          // Reduce the MD5 hash to a single unsigned long
          byte[] result = new byte[] { md5[3], md5[2], md5[1], md5[0] };
          return toHex(result);
      }
docs: Generates a hex X509_NAME hash (like openssl x509 -hash -in cert.pem)
  Based on openssl's crypto/x509/x509_cmp.c line 321