title: Is the Https connection trust, If Https cert public key is same? (HttpClient5)
body: <p>In PKI system, You can use CA public key to verify a certificate:</p>
  <pre class="lang-java prettyprint-override"><code>x509Certificate.verify(CAPublicKey);
  </code></pre>
  <p>But I want only trust the specified certificate rather than whole CA and all certs he sign. You can't verify an cert with itself public key And this won't work Then throw exception:</p>
  <pre class="lang-java prettyprint-override"><code>x509Certificate.verify(currentCertificatePublicKey);
  </code></pre>
  <p><code>java.security.SignatureException: Signature does not match</code></p>
  <p>So I try to do that:</p>
  <pre class="lang-java prettyprint-override"><code>x509Certificate.getPublicKey().getEncoded().equals(currentCertificatePublicKey);
  </code></pre>
  <p>This working but I'm not sure is that safe. I did some research but I still can't 100% sure for it because none use https like that, So the question is:</p>
  <p>Is there any possibility to cheat https client without certificate private key? (TLS_1.2)</p>