Add wrapper for getting X509_digest from a cert
[folly.git] / folly / ssl / OpenSSLCertUtils.h
index 373fde01b37c6e96beb88120cabd7e3ec9b5f5ed..31273d02ae797814d643ad0ca99b6802bf0ebd6b 100644 (file)
@@ -76,8 +76,22 @@ class OpenSSLCertUtils {
    */
   static std::unique_ptr<IOBuf> derEncode(X509&);
 
+  /**
+   * Reads certificates from memory and returns them as a vector of X509
+   * pointers.
+   */
+  static std::vector<X509UniquePtr> readCertsFromBuffer(ByteRange);
+
+  /**
+   * Return the output of the X509_digest for chosen message-digest algo
+   * NOTE: The returned digest will be in binary, and may need to be
+   * hex-encoded
+   */
+  static std::array<uint8_t, SHA_DIGEST_LENGTH> getDigestSha1(X509& x509);
+  static std::array<uint8_t, SHA256_DIGEST_LENGTH> getDigestSha256(X509& x509);
+
  private:
   static std::string getDateTimeStr(const ASN1_TIME* time);
 };
-}
-}
+} // namespace ssl
+} // namespace folly