XRootD
XrdTlsPeerCerts Class Reference

#include <XrdTlsPeerCerts.hh>

+ Collaboration diagram for XrdTlsPeerCerts:

Public Member Functions

 XrdTlsPeerCerts (X509 *pCert=0, STACK_OF(X509) *pChain=0)
 
 ~XrdTlsPeerCerts ()
 
X509 * getCert (bool upref=true)
 
bool hasCert ()
 
bool hasChain ()
 
 STACK_OF (X509) *getChain()
 

Detailed Description

Definition at line 34 of file XrdTlsPeerCerts.hh.

Constructor & Destructor Documentation

◆ XrdTlsPeerCerts()

XrdTlsPeerCerts::XrdTlsPeerCerts ( X509 *  pCert = 0,
STACK_OF(X509) *  pChain = 0 
)
inline

Constructor

Parameters
pCert- pointer to the cert.
pChain- pointer to the chain.

Definition at line 93 of file XrdTlsPeerCerts.hh.

94  : cert(pCert), chain(pChain) {}

◆ ~XrdTlsPeerCerts()

XrdTlsPeerCerts::~XrdTlsPeerCerts ( )

Definition at line 61 of file XrdTlsPeerCerts.cc.

62 {
63 // Free the peer cert
64 //
65 if (cert) X509_free(cert);
66 
67 // Free the chain (we don't have to as only get1 call creates a copy.
68 //
69 // if (chain) sk_X509_pop_free(chain, X509_free);
70 }

Member Function Documentation

◆ getCert()

X509 * XrdTlsPeerCerts::getCert ( bool  upref = true)

Obtain pointer to the cert.

Parameters
uprefWhen true the cert reference count is increased by one. Otherwise, the reference count stays the same (see note).
Returns
Upon success, the pointer to the cert is returned. Upon failure, a nil pointer is returned.
Note
If the cert is being passed to a method that will call X509_free() on the cert (many do) the reference count must be increased as the destructor decreases the reference count. Incorrrect handling of the reference count will invariable SEGV when the session is freed. Do not pass the cert to an opaque method without verifying how it handles the cert upon return.

Definition at line 76 of file XrdTlsPeerCerts.cc.

77 {
78 // If we have a cert and we need to up the reference, do so. Note that upref
79 // may fail; in which case we return a nil pointer to avoid a future segv.
80 //
81  if (cert && upref && !X509_up_ref(cert)) return 0;
82  return cert;
83 }

Referenced by XrdCryptosslX509ParseStack().

+ Here is the caller graph for this function:

◆ hasCert()

bool XrdTlsPeerCerts::hasCert ( )
inline

Check if this object has a cert.

Returns
True if a cert is present and false otherwise.

Definition at line 76 of file XrdTlsPeerCerts.hh.

76 {return cert != 0;}

Referenced by XrdCryptosslX509ParseStack().

+ Here is the caller graph for this function:

◆ hasChain()

bool XrdTlsPeerCerts::hasChain ( )
inline

Check if this object has a chain.

Returns
True if a chain is present and false otherwise.

Definition at line 84 of file XrdTlsPeerCerts.hh.

84 {return chain != 0;}

Referenced by XrdCryptosslX509ParseStack().

+ Here is the caller graph for this function:

◆ STACK_OF()

XrdTlsPeerCerts::STACK_OF ( X509  )
inline

Obtain pointer to the chain.

Returns
Upon success, the pointer to the cert is returned which may be nil if there is no chain.
Note
The chain is the actual chain associated with the SSL session. When he SSL session is freed, the chain becomes invalid and all references to it must cease.

Definition at line 68 of file XrdTlsPeerCerts.hh.

68 {return chain;}

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