Botan  2.4.0
Crypto and TLS for C++11
Public Types | Public Member Functions | Static Public Member Functions | List of all members
Botan::Path_Validation_Result Class Referencefinal

#include <x509path.h>

Public Types

typedef Certificate_Status_Code Code
 

Public Member Functions

const CertificatePathStatusCodesall_statuses () const
 
const std::vector< std::shared_ptr< const X509_Certificate > > & cert_path () const
 
bool no_warnings () const
 
 Path_Validation_Result (CertificatePathStatusCodes status, std::vector< std::shared_ptr< const X509_Certificate >> &&cert_chain)
 
 Path_Validation_Result (Certificate_Status_Code status)
 
Certificate_Status_Code result () const
 
std::string result_string () const
 
bool successful_validation () const
 
const X509_Certificatetrust_root () const
 
std::set< std::string > trusted_hashes () const
 
CertificatePathStatusCodes warnings () const
 

Static Public Member Functions

static const char * status_string (Certificate_Status_Code code)
 

Detailed Description

Represents the result of a PKIX path validation

Definition at line 110 of file x509path.h.

Member Typedef Documentation

◆ Code

Definition at line 113 of file x509path.h.

Constructor & Destructor Documentation

◆ Path_Validation_Result() [1/2]

Botan::Path_Validation_Result::Path_Validation_Result ( CertificatePathStatusCodes  status,
std::vector< std::shared_ptr< const X509_Certificate >> &&  cert_chain 
)

Create a Path_Validation_Result

Parameters
statuslist of validation status codes
cert_chainthe certificate chain that was validated

Definition at line 986 of file x509path.cpp.

987  :
988  m_all_status(status),
989  m_warnings(find_warnings(m_all_status)),
990  m_cert_path(cert_chain),
991  m_overall(PKIX::overall_status(m_all_status))
992  {
993  }
Certificate_Status_Code overall_status(const CertificatePathStatusCodes &cert_status)
Definition: x509path.cpp:797

◆ Path_Validation_Result() [2/2]

Botan::Path_Validation_Result::Path_Validation_Result ( Certificate_Status_Code  status)
inlineexplicit

Create a Path_Validation_Result

Parameters
statusvalidation status code

Definition at line 182 of file x509path.h.

References BOTAN_PUBLIC_API, Botan::UNSPECIFIED, and Botan::x509_path_validate().

182 : m_overall(status) {}

Member Function Documentation

◆ all_statuses()

const CertificatePathStatusCodes& Botan::Path_Validation_Result::all_statuses ( ) const
inline
Returns
a set of status codes for each certificate in the chain

Definition at line 151 of file x509path.h.

152  { return m_all_status; }

◆ cert_path()

const std::vector<std::shared_ptr<const X509_Certificate> >& Botan::Path_Validation_Result::cert_path ( ) const
inline
Returns
the full path from subject to trust root This path may be empty

Definition at line 131 of file x509path.h.

131 { return m_cert_path; }

◆ no_warnings()

bool Botan::Path_Validation_Result::no_warnings ( ) const
Returns
true iff no warnings occured during validation

Definition at line 1020 of file x509path.cpp.

1021  {
1022  return m_warnings.empty();
1023  }

◆ result()

Certificate_Status_Code Botan::Path_Validation_Result::result ( ) const
inline
Returns
overall validation result code

Definition at line 146 of file x509path.h.

Referenced by result_string(), successful_validation(), and trust_root().

146 { return m_overall; }

◆ result_string()

std::string Botan::Path_Validation_Result::result_string ( ) const
Returns
string representation of the validation result

Definition at line 1030 of file x509path.cpp.

References result(), and status_string().

1031  {
1032  return status_string(result());
1033  }
static const char * status_string(Certificate_Status_Code code)
Definition: x509path.cpp:1035
Certificate_Status_Code result() const
Definition: x509path.h:146

◆ status_string()

const char * Botan::Path_Validation_Result::status_string ( Certificate_Status_Code  code)
static
Parameters
codevalidation status code
Returns
corresponding validation status message

Definition at line 1035 of file x509path.cpp.

References Botan::to_string().

Referenced by result_string().

1036  {
1037  if(const char* s = to_string(code))
1038  return s;
1039 
1040  return "Unknown error";
1041  }
std::string to_string(const secure_vector< uint8_t > &bytes)
Definition: stl_util.h:25

◆ successful_validation()

bool Botan::Path_Validation_Result::successful_validation ( ) const

◆ trust_root()

const X509_Certificate & Botan::Path_Validation_Result::trust_root ( ) const
Returns
the trust root of the validation if successful throws an exception if the validation failed

Definition at line 995 of file x509path.cpp.

References result(), and Botan::VERIFIED.

996  {
997  if(m_cert_path.empty())
998  throw Exception("Path_Validation_Result::trust_root no path set");
1000  throw Exception("Path_Validation_Result::trust_root meaningless with invalid status");
1001 
1002  return *m_cert_path[m_cert_path.size()-1];
1003  }
Certificate_Status_Code result() const
Definition: x509path.h:146

◆ trusted_hashes()

std::set< std::string > Botan::Path_Validation_Result::trusted_hashes ( ) const
Returns
the set of hash functions you are implicitly trusting by trusting this result.

Definition at line 1005 of file x509path.cpp.

1006  {
1007  std::set<std::string> hashes;
1008  for(size_t i = 0; i != m_cert_path.size(); ++i)
1009  hashes.insert(m_cert_path[i]->hash_used_for_signature());
1010  return hashes;
1011  }

◆ warnings()

CertificatePathStatusCodes Botan::Path_Validation_Result::warnings ( ) const
Returns
the subset of status codes that are warnings

Definition at line 1025 of file x509path.cpp.

1026  {
1027  return m_warnings;
1028  }

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