proxygen
fizz::PeerCertImpl< T > Class Template Reference

#include <Certificate.h>

Inheritance diagram for fizz::PeerCertImpl< T >:
fizz::PeerCert folly::AsyncTransportCertificate

Public Member Functions

 PeerCertImpl (folly::ssl::X509UniquePtr cert)
 
 ~PeerCertImpl () override=default
 
std::string getIdentity () const override
 
void verify (SignatureScheme scheme, CertificateVerifyContext context, folly::ByteRange toBeSigned, folly::ByteRange signature) const override
 
folly::ssl::X509UniquePtr getX509 () const override
 
template<>
void verify (SignatureScheme scheme, CertificateVerifyContext context, folly::ByteRange toBeSigned, folly::ByteRange signature) const
 
template<>
void verify (SignatureScheme scheme, CertificateVerifyContext context, folly::ByteRange toBeSigned, folly::ByteRange signature) const
 
template<>
void verify (SignatureScheme scheme, CertificateVerifyContext context, folly::ByteRange toBeSigned, folly::ByteRange signature) const
 
template<>
void verify (SignatureScheme scheme, CertificateVerifyContext context, folly::ByteRange toBeSigned, folly::ByteRange signature) const
 
- Public Member Functions inherited from fizz::PeerCert
virtual ~PeerCert ()=default
 
- Public Member Functions inherited from folly::AsyncTransportCertificate
virtual ~AsyncTransportCertificate ()=default
 

Private Attributes

OpenSSLSignature< Tsignature_
 
folly::ssl::X509UniquePtr cert_
 

Detailed Description

template<KeyType T>
class fizz::PeerCertImpl< T >

Definition at line 176 of file Certificate.h.

Constructor & Destructor Documentation

template<KeyType T>
fizz::PeerCertImpl< T >::PeerCertImpl ( folly::ssl::X509UniquePtr  cert)
explicit

Definition at line 147 of file Certificate-inl.h.

References folly::gen::move.

147  {
148  folly::ssl::EvpPkeyUniquePtr key(X509_get_pubkey(cert.get()));
149  if (!key) {
150  throw std::runtime_error("could not get key from cert");
151  }
152  signature_.setKey(std::move(key));
153  cert_ = std::move(cert);
154 }
folly::ssl::X509UniquePtr cert_
Definition: Certificate.h:194
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
std::unique_ptr< EVP_PKEY, EvpPkeyDeleter > EvpPkeyUniquePtr
OpenSSLSignature< T > signature_
Definition: Certificate.h:193
template<KeyType T>
fizz::PeerCertImpl< T >::~PeerCertImpl ( )
overridedefault

Member Function Documentation

template<KeyType T>
std::string fizz::PeerCertImpl< T >::getIdentity ( ) const
overridevirtual

Returns the identity this certificate conveys.

An identity is an opaque string that may be used by the application for authentication or authorization purposes. The exact structure and semantics of the identity string are determined by concrete implementations of AsyncTransport.

Implements folly::AsyncTransportCertificate.

Definition at line 157 of file Certificate-inl.h.

References folly::ssl::OpenSSLCertUtils::getCommonName(), and folly::Optional< Value >::value_or().

157  {
159 }
static Optional< std::string > getCommonName(X509 &x509)
FOLLY_CPP14_CONSTEXPR Value value_or(U &&dflt) const &
Definition: Optional.h:330
template<KeyType T>
folly::ssl::X509UniquePtr fizz::PeerCertImpl< T >::getX509 ( ) const
overridevirtual

Returns an X509 structure associated with this Certificate. This may be null.

Implements folly::AsyncTransportCertificate.

Definition at line 226 of file Certificate-inl.h.

Referenced by fizz::test::TEST().

226  {
227  X509_up_ref(cert_.get());
228  return folly::ssl::X509UniquePtr(cert_.get());
229 }
std::unique_ptr< X509, X509Deleter > X509UniquePtr
folly::ssl::X509UniquePtr cert_
Definition: Certificate.h:194
template<>
void fizz::PeerCertImpl< KeyType::P256 >::verify ( SignatureScheme  scheme,
CertificateVerifyContext  context,
folly::ByteRange  toBeSigned,
folly::ByteRange  signature 
) const
inlinevirtual

Verifies that signature is a valid signature of toBeSigned. Throws if it's not.

Implements fizz::PeerCert.

Definition at line 162 of file Certificate-inl.h.

166  {
167  auto signData = CertUtils::prepareSignData(context, toBeSigned);
168  switch (scheme) {
171  signData->coalesce(), signature);
172  default:
173  throw std::runtime_error("Unsupported signature scheme");
174  }
175 }
context
Definition: CMakeCache.txt:563
OpenSSLSignature< T > signature_
Definition: Certificate.h:193
static Buf prepareSignData(CertificateVerifyContext context, folly::ByteRange toBeSigned)
Definition: Certificate.cpp:23
template<>
void fizz::PeerCertImpl< KeyType::P384 >::verify ( SignatureScheme  scheme,
CertificateVerifyContext  context,
folly::ByteRange  toBeSigned,
folly::ByteRange  signature 
) const
inlinevirtual

Verifies that signature is a valid signature of toBeSigned. Throws if it's not.

Implements fizz::PeerCert.

Definition at line 178 of file Certificate-inl.h.

182  {
183  auto signData = CertUtils::prepareSignData(context, toBeSigned);
184  switch (scheme) {
187  signData->coalesce(), signature);
188  default:
189  throw std::runtime_error("Unsupported signature scheme");
190  }
191 }
context
Definition: CMakeCache.txt:563
OpenSSLSignature< T > signature_
Definition: Certificate.h:193
static Buf prepareSignData(CertificateVerifyContext context, folly::ByteRange toBeSigned)
Definition: Certificate.cpp:23
template<KeyType T>
void fizz::PeerCertImpl< T >::verify ( SignatureScheme  scheme,
CertificateVerifyContext  context,
folly::ByteRange  toBeSigned,
folly::ByteRange  signature 
) const
overridevirtual

Verifies that signature is a valid signature of toBeSigned. Throws if it's not.

Implements fizz::PeerCert.

Referenced by fizz::test::TYPED_TEST().

template<>
void fizz::PeerCertImpl< KeyType::P521 >::verify ( SignatureScheme  scheme,
CertificateVerifyContext  context,
folly::ByteRange  toBeSigned,
folly::ByteRange  signature 
) const
inlinevirtual

Verifies that signature is a valid signature of toBeSigned. Throws if it's not.

Implements fizz::PeerCert.

Definition at line 194 of file Certificate-inl.h.

198  {
199  auto signData = CertUtils::prepareSignData(context, toBeSigned);
200  switch (scheme) {
203  signData->coalesce(), signature);
204  default:
205  throw std::runtime_error("Unsupported signature scheme");
206  }
207 }
context
Definition: CMakeCache.txt:563
OpenSSLSignature< T > signature_
Definition: Certificate.h:193
static Buf prepareSignData(CertificateVerifyContext context, folly::ByteRange toBeSigned)
Definition: Certificate.cpp:23
template<>
void fizz::PeerCertImpl< KeyType::RSA >::verify ( SignatureScheme  scheme,
CertificateVerifyContext  context,
folly::ByteRange  toBeSigned,
folly::ByteRange  signature 
) const
inlinevirtual

Verifies that signature is a valid signature of toBeSigned. Throws if it's not.

Implements fizz::PeerCert.

Definition at line 210 of file Certificate-inl.h.

214  {
215  auto signData = CertUtils::prepareSignData(context, toBeSigned);
216  switch (scheme) {
219  signData->coalesce(), signature);
220  default:
221  throw std::runtime_error("Unsupported signature scheme");
222  }
223 }
context
Definition: CMakeCache.txt:563
OpenSSLSignature< T > signature_
Definition: Certificate.h:193
static Buf prepareSignData(CertificateVerifyContext context, folly::ByteRange toBeSigned)
Definition: Certificate.cpp:23

Member Data Documentation

template<KeyType T>
folly::ssl::X509UniquePtr fizz::PeerCertImpl< T >::cert_
private

Definition at line 194 of file Certificate.h.

template<KeyType T>
OpenSSLSignature<T> fizz::PeerCertImpl< T >::signature_
private

Definition at line 193 of file Certificate.h.


The documentation for this class was generated from the following files: