xrootd
Main Page
Namespaces
Classes
Files
File List
File Members
src
XrdCrypto
XrdCryptoX509Chain.hh
Go to the documentation of this file.
1
// $Id$
2
#ifndef __CRYPTO_X509CHAIN_H__
3
#define __CRYPTO_X509CHAIN_H__
4
/******************************************************************************/
5
/* */
6
/* X r d C r y p t o X 5 0 9 C h a i n . h h */
7
/* */
8
/* (c) 2005 G. Ganis , CERN */
9
/* */
10
/******************************************************************************/
11
12
/* ************************************************************************** */
13
/* */
14
/* Chain of X509 certificates. */
15
/* */
16
/* ************************************************************************** */
17
18
#include <
XrdSut/XrdSutBucket.hh
>
19
#include <
XrdCrypto/XrdCryptoX509.hh
>
20
#include <
XrdCrypto/XrdCryptoX509Crl.hh
>
21
22
// ---------------------------------------------------------------------------//
23
// //
24
// XrdCryptoX509Chain //
25
// //
26
// Light single-linked list for managing stacks of XrdCryptoX509* objects //
27
// //
28
// ---------------------------------------------------------------------------//
29
30
//
31
// Description of options for verify
32
typedef
struct
{
33
int
opt
;
// option container
34
int
when
;
// time of verification (UTC)
35
int
pathlen
;
// max allowed path length of chain
36
XrdCryptoX509Crl
*
crl
;
// CRL
37
}
x509ChainVerifyOpt_t
;
38
39
const
int
kOptsCheckSelfSigned
= 0x2;
// CA ckecking option
40
41
//
42
// Node definition
43
//
44
class
XrdCryptoX509ChainNode
{
45
46
private
:
47
XrdCryptoX509
*
cert
;
48
XrdCryptoX509ChainNode
*
next
;
49
public
:
50
XrdCryptoX509ChainNode
(
XrdCryptoX509
*c = 0,
XrdCryptoX509ChainNode
*n = 0)
51
{
cert
= c;
next
= n;}
52
virtual
~XrdCryptoX509ChainNode
() { }
53
54
XrdCryptoX509
*
Cert
()
const
{
return
cert
; }
55
XrdCryptoX509ChainNode
*
Next
()
const
{
return
next
; }
56
57
void
SetNext
(
XrdCryptoX509ChainNode
*n) {
next
= n; }
58
};
59
60
class
XrdCryptoX509Chain
{
61
62
friend
class
XrdCryptosslgsiX509Chain
;
63
64
enum
ESearchMode
{
kExact
= 0,
kBegin
= 1,
kEnd
= 2 };
65
66
public
:
67
XrdCryptoX509Chain
(
XrdCryptoX509
*c = 0);
68
XrdCryptoX509Chain
(
XrdCryptoX509Chain
*ch);
69
virtual
~XrdCryptoX509Chain
();
70
71
// CA status
72
enum
ECAStatus
{
kUnknown
= 0,
kAbsent
,
kInvalid
,
kValid
};
73
74
// Error codes
75
enum
EX509ChainErr
{
kNone
= 0,
kInconsistent
,
kTooMany
,
kNoCA
,
76
kNoCertificate
,
kInvalidType
,
kInvalidNames
,
77
kRevoked
,
kExpired
,
kMissingExtension
,
78
kVerifyFail
,
kInvalidSign
,
kCANotAutoSigned
};
79
80
// In case or error
81
const
char
*
X509ChainError
(
EX509ChainErr
e);
82
const
char
*
LastError
()
const
{
return
lastError
.
c_str
(); }
83
84
// Dump content
85
void
Dump
();
86
87
// Access information
88
int
Size
()
const
{
return
size
; }
89
XrdCryptoX509
*
End
()
const
{
return
end
->
Cert
(); }
90
ECAStatus
StatusCA
()
const
{
return
statusCA
; }
91
const
char
*
CAname
();
92
const
char
*
EECname
();
93
const
char
*
CAhash
();
94
const
char
*
EEChash
();
95
96
// Modifiers
97
void
InsertAfter
(
XrdCryptoX509
*c,
XrdCryptoX509
*cp);
98
void
PutInFront
(
XrdCryptoX509
*c);
99
void
PushBack
(
XrdCryptoX509
*c);
100
void
Remove
(
XrdCryptoX509
*c);
101
bool
CheckCA
(
bool
checkselfsigned = 1);
102
void
Cleanup
(
bool
keepCA = 0);
103
void
SetStatusCA
(
ECAStatus
st) {
statusCA
= st; }
104
105
// Search
106
XrdCryptoX509
*
SearchByIssuer
(
const
char
*issuer,
107
ESearchMode
mode =
kExact
);
108
XrdCryptoX509
*
SearchBySubject
(
const
char
*subject,
109
ESearchMode
mode =
kExact
);
110
111
// Check validity in time
112
virtual
int
CheckValidity
(
bool
outatfirst = 1,
int
when = 0);
113
114
// Reorder (C(n) issuer of C(n+1))
115
virtual
int
Reorder
();
116
117
// Verify chain
118
virtual
bool
Verify
(
EX509ChainErr
&e,
x509ChainVerifyOpt_t
*vopt = 0);
119
120
// Pseudo - iterator functionality
121
XrdCryptoX509
*
Begin
();
122
XrdCryptoX509
*
Next
();
123
124
private
:
125
126
127
XrdCryptoX509ChainNode
*
begin
;
128
XrdCryptoX509ChainNode
*
current
;
129
XrdCryptoX509ChainNode
*
end
;
130
XrdCryptoX509ChainNode
*
previous
;
131
int
size
;
132
XrdOucString
lastError
;
133
XrdOucString
caname
;
134
XrdOucString
eecname
;
135
XrdOucString
cahash
;
136
XrdOucString
eechash
;
137
ECAStatus
statusCA
;
138
139
XrdCryptoX509ChainNode
*
Find
(
XrdCryptoX509
*c);
140
XrdCryptoX509ChainNode
*
FindIssuer
(
const
char
*issuer,
141
ESearchMode
mode =
kExact
,
142
XrdCryptoX509ChainNode
**p = 0);
143
XrdCryptoX509ChainNode
*
FindSubject
(
const
char
*subject,
144
ESearchMode
mode =
kExact
,
145
XrdCryptoX509ChainNode
**p = 0);
146
bool
Verify
(
EX509ChainErr
&e,
const
char
*msg,
147
XrdCryptoX509::EX509Type
type,
int
when,
148
XrdCryptoX509
*xcer,
XrdCryptoX509
*xsig,
149
XrdCryptoX509Crl
*crl = 0);
150
151
};
152
153
#endif
Generated by
1.8.1.2