LCOV - code coverage report
Current view: top level - envoy/ssl - ssl_socket_extended_info.h (source / functions) Hit Total Coverage
Test: coverage.dat Lines: 0 2 0.0 %
Date: 2024-01-05 06:35:25 Functions: 0 2 0.0 %

          Line data    Source code
       1             : #pragma once
       2             : 
       3             : #include <cstdint>
       4             : #include <memory>
       5             : #include <string>
       6             : #include <vector>
       7             : 
       8             : #include "envoy/common/pure.h"
       9             : #include "envoy/event/dispatcher.h"
      10             : 
      11             : namespace Envoy {
      12             : namespace Ssl {
      13             : 
      14             : enum class ClientValidationStatus { NotValidated, NoClientCertificate, Validated, Failed };
      15             : 
      16             : enum class ValidateStatus {
      17             :   NotStarted,
      18             :   Pending,
      19             :   Successful,
      20             :   Failed,
      21             : };
      22             : 
      23             : /**
      24             :  * Used to return the result from an asynchronous cert validation.
      25             :  */
      26             : class ValidateResultCallback {
      27             : public:
      28           0 :   virtual ~ValidateResultCallback() = default;
      29             : 
      30             :   virtual Event::Dispatcher& dispatcher() PURE;
      31             : 
      32             :   /**
      33             :    * Called when the asynchronous cert validation completes.
      34             :    * @param succeeded true if the validation succeeds
      35             :    * @param detailed_status detailed status of the underlying validation. Depending on the
      36             :    *        validation configuration, `succeeded` may be true but `detailed_status` might
      37             :    *        indicate a failure. This detailed status can be used to inform routing
      38             :    *        decisions.
      39             :    * @param error_details failure details, only used if the validation fails.
      40             :    * @param tls_alert the TLS error related to the failure, only used if the validation fails.
      41             :    */
      42             :   virtual void onCertValidationResult(bool succeeded, ClientValidationStatus detailed_status,
      43             :                                       const std::string& error_details, uint8_t tls_alert) PURE;
      44             : };
      45             : 
      46             : using ValidateResultCallbackPtr = std::unique_ptr<ValidateResultCallback>;
      47             : 
      48             : class SslExtendedSocketInfo {
      49             : public:
      50           0 :   virtual ~SslExtendedSocketInfo() = default;
      51             : 
      52             :   /**
      53             :    * Set the peer certificate validation status.
      54             :    **/
      55             :   virtual void setCertificateValidationStatus(ClientValidationStatus validated) PURE;
      56             : 
      57             :   /**
      58             :    * @return ClientValidationStatus The peer certificate validation status.
      59             :    **/
      60             :   virtual ClientValidationStatus certificateValidationStatus() const PURE;
      61             : 
      62             :   /**
      63             :    * @return ValidateResultCallbackPtr a callback used to return the validation result.
      64             :    */
      65             :   virtual ValidateResultCallbackPtr createValidateResultCallback() PURE;
      66             : 
      67             :   /**
      68             :    * Called after the cert validation completes either synchronously or asynchronously.
      69             :    * @param succeeded true if the validation succeeded.
      70             :    * @param async true if the validation is completed asynchronously.
      71             :    */
      72             :   virtual void onCertificateValidationCompleted(bool succeeded, bool async) PURE;
      73             : 
      74             :   /**
      75             :    * @return ValidateStatus the validation status.
      76             :    */
      77             :   virtual ValidateStatus certificateValidationResult() const PURE;
      78             : 
      79             :   /**
      80             :    * Called when doing asynchronous cert validation.
      81             :    * @return uint8_t represents the TLS alert populated by cert validator in
      82             :    * case of failure.
      83             :    */
      84             :   virtual uint8_t certificateValidationAlert() const PURE;
      85             : };
      86             : 
      87             : } // namespace Ssl
      88             : } // namespace Envoy

Generated by: LCOV version 1.15