title: Certificate Pinning - Generate SHA256 Pinning Key from Certificate .crt file
body: <p>I have a running Android application that implements Certificate Pinning with a SHA256 Pin. I use the <a href="https://www.ssllabs.com/ssltest" rel="nofollow noreferrer">https://www.ssllabs.com/ssltest</a> tool to obtain that pin.</p>
  <p>The current server certificate is about to expire, and a new certificate will be applied to the server. I need to generate the SHA256 Pin for the new certificate before it is applied to the server so that I can add it to the application and introduce it in an update.</p>
  <p>I have the new certificate .crt file. Any idea how to generate the SHA256 key from the file? I have no access to the server, just the .crt file.</p>
  <p>As per OkHttp's CertificatePinner documentation:</p>
  <blockquote>
  <p>SHA-256 or SHA-1 hashes. Each pin is a hash of a certificate's Subject
  Public Key Info, base64-encoded and prefixed with either sha256/ or
  sha1/.</p>
  </blockquote>