#ifndef RTC_CERTIFICATE_H
#define RTC_CERTIFICATE_H
#include "include.hpp"
#include "tls.hpp"
#include <future>
#include <tuple>
namespace rtc {
class Certificate {
public:
Certificate(string crt_pem, string key_pem);
#if USE_GNUTLS
Certificate(gnutls_x509_crt_t crt, gnutls_x509_privkey_t privkey);
gnutls_certificate_credentials_t credentials() const;
#else
Certificate(std::shared_ptr<X509> x509, std::shared_ptr<EVP_PKEY> pkey);
std::tuple<X509 *, EVP_PKEY *> credentials() const;
#endif
string fingerprint() const;
private:
#if USE_GNUTLS
std::shared_ptr<gnutls_certificate_credentials_t> mCredentials;
#else
std::shared_ptr<X509> mX509;
std::shared_ptr<EVP_PKEY> mPKey;
#endif
string mFingerprint;
};
#if USE_GNUTLS
string make_fingerprint(gnutls_x509_crt_t crt);
#else
string make_fingerprint(X509 *x509);
#endif
using certificate_ptr = std::shared_ptr<Certificate>;
using future_certificate_ptr = std::shared_future<certificate_ptr>;
future_certificate_ptr make_certificate(string commonName = "libdatachannel");
void CleanupCertificateCache();
}
#endif