File: pkix_certs.html

package info (click to toggle)
erlang-doc-html 1%3A12.b.3-dfsg-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 27,712 kB
  • ctags: 13,052
  • sloc: erlang: 505; ansic: 323; perl: 61; makefile: 57; sh: 23
file content (391 lines) | stat: -rw-r--r-- 12,267 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!-- This document was generated using DocBuilder-0.9.8.4 -->
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>PKIX Certificates</title>
  <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
  <script type="text/javascript" src="../../../../doc/erlresolvelinks.js"></script>
  <style type="text/css">
<!--
    body          { font-family: Verdana, Arial, Helvetica, sans-serif }
    span.bold_code        { font-family: courier;font-weight: bold}
    span.code        { font-family: courier;font-weight: normal}

.note, .warning {
  border: solid black 1px;
  margin: 1em 3em;
}

.note .label {
  background: #30d42a;
  color: white;
  font-weight: bold;
  padding: 5px 10px;
}
.note .content {
  background: #eafeea;
  color: black;
  line-height: 120%;
  font-size: 90%;
  padding: 5px 10px;
}
.warning .label {
  background: #C00;
  color: white;
  font-weight: bold;
  padding: 5px 10px;
}
.warning .content {
  background: #FFF0F0;
  color: black;
  line-height: 120%;
  font-size: 90%;
  padding: 5px 10px;
}

    .example     { background-color:#eeeeff } 
    pre          { font-family: courier; font-weight: normal }
    .REFBODY     { margin-left: 13mm }
    .REFTYPES    { margin-left: 8mm }
-->
  </style>
</head>
<body bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#FF00FF" alink="#FF0000">
<center>
<a href="http://www.ericsson.com/technology/opensource/erlang"><img border="0" alt="[Ericsson AB]" src="min_head.gif"/></a>
</center><a name="3"><!-- Empty --></a>
<h2>3 PKIX Certificates</h2>
<a name="3.1"><!-- Empty --></a>
<h3>3.1 Introduction to Certificates</h3>

<p>Certificates were originally defined by ITU (CCITT) and the latest 
definitions are described in <a href="usersguide_cite.html#X.509">X.509</a> , but those definitions
are (as always) not working. 

</p>
<p>Working certificate definitions for the Internet Community are found
in the the PKIX RFCs <a href="usersguide_cite.html#rfc3279">rfc3279</a> and <a href="usersguide_cite.html#rfc3280">rfc3280</a> . 
The parsing of certificates in the Erlang/OTP SSL application is
based on those RFCS. 

</p>
<p>Certificates are defined in terms of ASN.1 (<a href="usersguide_cite.html#X.680">ITU-T X.680</a> ).
For an introduction to ASN.1 see <a target="_top" href="http://asn1.elibel.tm.fr/">ASN.1 Information Site</a>.

</p><a name="3.2"><!-- Empty --></a>
<h3>3.2 PKIX Certificates</h3>

<p>Here we base the PKIX certificate definitions in RFCs <a href="usersguide_cite.html#rfc3279">rfc3279</a> and <a href="usersguide_cite.html#rfc3280">rfc3280</a> . We however present the
definitions according to <span class="code">SSL-PKIX.asn1</span> module, 
which is an amelioration of the <span class="code">PKIX1Explicit88.asn1</span>, 
<span class="code">PKIX1Implicit88.asn1</span>, and <span class="code">PKIX1Algorithms88.asn1</span>
modules. You find all these modules in the <span class="code">pkix</span> subdirectory
of SSL. 

</p>
<p>The Erlang terms that are returned by the functions
<span class="code">ssl:peercert/1/2</span>, <span class="code">ssl_pkix:decode_cert/1/2</span>, and
<span class="code">ssl_pkix:decode_cert_file/1/2</span> when the option <span class="code">ssl</span>
is used in those functions, correspond the ASN.1 structures
described in the sequel. 

</p><a name="3.2.1"><!-- Empty --></a>
<h4>3.2.1 Certificate and TBSCertificate</h4>

<div class="example"><pre>
Certificate  ::=  SEQUENCE  {
     tbsCertificate       TBSCertificate,
     signatureAlgorithm   SignatureAlgorithm,
     signature            BIT STRING }

TBSCertificate  ::=  SEQUENCE  {
     version         [0]  Version DEFAULT v1,
     serialNumber         CertificateSerialNumber,
     signature            SignatureAlgorithm,
     issuer               Name,
     validity             Validity,
     subject              Name,
     subjectPublicKeyInfo SubjectPublicKeyInfo,
     issuerUniqueID  [1]  IMPLICIT UniqueIdentifier OPTIONAL,
                          -- If present, version MUST be v2 or v3
     subjectUniqueID [2]  IMPLICIT UniqueIdentifier OPTIONAL,
                          -- If present, version MUST be v2 or v3
     extensions      [3]  Extensions OPTIONAL
                          -- If present, version MUST be v3 --  }

Version  ::=  INTEGER  {  v1(0), v2(1), v3(2)  }

CertificateSerialNumber  ::=  INTEGER

Validity ::= SEQUENCE {
     notBefore      Time,
     notAfter       Time  }

Time ::= CHOICE {
     utcTime        UTCTime,
     generalTime    GeneralizedTime }
      
</pre></div>

<p>The meaning of the fields <span class="code">version</span>, <span class="code">serialNumber</span>,
and <span class="code">validity</span> are quite obvious given the type definitions
above, so we do not go further into their details. 

</p>
<p>The <span class="code">signatureAlgorithm</span> field of <span class="code">Certificate</span> and
the <span class="code">signature</span> field of <span class="code">TBSCertificate</span> contain
the name and parameters of the algorithm used for signing the
certificate. The values of these two fields must be equal.

</p>
<p>The <span class="code">signature</span> field of <span class="code">Certificate</span> contains the
value of the signature that the issuer computed by using the 
prescribed algorithm.

</p>
<p>The <span class="code">issuer&#60;c&#62; and &#60;c&#62;subject</span> fields can contain many 
different types av data, and is therefore considered in a 
separate section. The same holds for the <span class="code">extensions</span>
field. 
The <span class="code">issuerUniqueID</span> and the <span class="code">subjectUniqueID</span> fields 
are not considered further.
</p><a name="3.2.2"><!-- Empty --></a>
<h4>3.2.2 TBSCertificate issuer and subject</h4>

<p>
</p>
<div class="example"><pre>
Name ::= CHOICE { -- only one possibility for now --
      rdnSequence  RDNSequence }

RDNSequence ::= SEQUENCE OF RelativeDistinguishedName

DistinguishedName ::=   RDNSequence

RelativeDistinguishedName  ::=
                    SET SIZE (1 .. MAX) OF AttributeTypeAndValue

AttributeTypeAndValue ::=  SEQUENCE {
        type    ATTRIBUTE-TYPE-AND-VALUE-CLASS.&#38;id
                ({SupportedAttributeTypeAndValues}),
        value   ATTRIBUTE-TYPE-AND-VALUE-CLASS.&#38;Type
                ({SupportedAttributeTypeAndValues}{@type}) }

SupportedAttributeTypeAndValues ATTRIBUTE-TYPE-AND-VALUE-CLASS ::= 
        { name | surname | givenName | initials | generationQualifier |
          commonName | localityName | stateOrProvinceName | organizationName |
          organizationalUnitName | title | dnQualifier | countryName |
          serialNumber | pseudonym | domainComponent | emailAddress }      
</pre></div>
<a name="3.2.3"><!-- Empty --></a>
<h4>3.2.3 TBSCertificate extensions</h4>

<p>The <span class="code">extensions</span> field of a <span class="code">TBScertificate</span> is a 
sequence of type <span class="code">Extension</span>, defined as follows,
</p>
<div class="example"><pre>
Extension  ::=  SEQUENCE  {
     extnID      OBJECT IDENTIFIER,
     critical    BOOLEAN DEFAULT FALSE,
     extnValue   ANY }      
</pre></div>

<p>Each extension has a unique object identifier. An extension
with a <span class="code">critical</span> value set to <span class="code">TRUE</span><strong>must</strong>
be recognised by the reader of a certificate, or else the
certificate must be rejected.

</p>
<p>Extensions are divided into two groups: standard extensions
and internet certificate extensions. All extensions listed in
the table that follows are standard extensions, except for
<span class="code">authorityInfoAccess</span> and <span class="code">subjectInfoAccess</span>, which
are internet extensions.

</p>
<p>Depending on the object identifier the <span class="code">extnValue</span> is
parsed into an appropriate welldefined structure. 

</p>
<p>The following table shows the purpose of each extension, but
does not specify the structure. To see the structure consult
the <span class="code">PKIX1Implicit88.asn1</span> module.

</p>
<center>
<table cellspacing="0" cellpadding="2" border="1">
  <caption align="bottom"><em>PKIX Extensions</em></caption>
  <tr>
    <td align="left" valign="middle">
authorityKeyIdentifier
    </td>
    <td align="left" valign="middle">
Used by to identify a certificate signed that has multiple signing keys. 
    </td>

  </tr>
  <tr>
    <td align="left" valign="middle">
subjectKeyIdentifier
    </td>
    <td align="left" valign="middle">
Used to identify certificates that contain a public key. Must appear i CA certificates.
    </td>

  </tr>
  <tr>
    <td align="left" valign="middle">
keyUsage 
    </td>
    <td align="left" valign="middle">
Defines the purpose of the certificate. Can be one or several of<span class="code">digitalSignature</span>, <span class="code">nonRepudiation</span>,<span class="code">keyEncipherment</span>, <span class="code">dataEncipherment</span>,<span class="code">keyAgreement</span>, <span class="code">keyCertSign</span>, <span class="code">cRLSign</span>,<span class="code">encipherOnly</span>, <span class="code">decipherOnly</span>.
    </td>

  </tr>
  <tr>
    <td align="left" valign="middle">
privateKeyUsagePeriod 
    </td>
    <td align="left" valign="middle">
Allows certificate issuer to provide a private key usage period to be short than the certificate usage period.
    </td>

  </tr>
  <tr>
    <td align="left" valign="middle">
certificatePolicies
    </td>
    <td align="left" valign="middle">
Contains one or more policy information terms indicating the policies under which the certificate has been issued.
    </td>

  </tr>
  <tr>
    <td align="left" valign="middle">
policyMappings
    </td>
    <td align="left" valign="middle">
Used i CA certificates. 
    </td>

  </tr>
  <tr>
    <td align="left" valign="middle">
subjectAltName
    </td>
    <td align="left" valign="middle">
Allows additional identities to be bound the the subject. 
    </td>

  </tr>
  <tr>
    <td align="left" valign="middle">
issuerAltName
    </td>
    <td align="left" valign="middle">
Allows additional identities to be bound the the issuer.
    </td>

  </tr>
  <tr>
    <td align="left" valign="middle">
subjectDirectoryAttributes
    </td>
    <td align="left" valign="middle">
Conveys identity attributes of the subject.
    </td>

  </tr>
  <tr>
    <td align="left" valign="middle">
basicConstraints
    </td>
    <td align="left" valign="middle">
Tells if the certificate holder is a CA or not.
    </td>

  </tr>
  <tr>
    <td align="left" valign="middle">
nameConstraints
    </td>
    <td align="left" valign="middle">
Used in CA certificates.
    </td>

  </tr>
  <tr>
    <td align="left" valign="middle">
policyConstraints
    </td>
    <td align="left" valign="middle">
Used in CA certificates.
    </td>

  </tr>
  <tr>
    <td align="left" valign="middle">
extKeyUsage
    </td>
    <td align="left" valign="middle">
Indicates for which purposed the public key may be used. 
    </td>

  </tr>
  <tr>
    <td align="left" valign="middle">
cRLDistributionPoints
    </td>
    <td align="left" valign="middle">
Indicates how CRL (Certificate Revokation List) information is obtained.
    </td>

  </tr>
  <tr>
    <td align="left" valign="middle">
inhibitAnyPolicy
    </td>
    <td align="left" valign="middle">
Used i CA certificates.
    </td>

  </tr>
  <tr>
    <td align="left" valign="middle">
freshestCRL
    </td>
    <td align="left" valign="middle">
For CRLs.
    </td>

  </tr>
  <tr>
    <td align="left" valign="middle">
authorityInfoAccess
    </td>
    <td align="left" valign="middle">
How to access CA information of the isssuer of the certificate.
    </td>

  </tr>
  <tr>
    <td align="left" valign="middle">
subjectInfoAccess
    </td>
    <td align="left" valign="middle">
How to access CA information of the subject of the certificate.
    </td>

  </tr>

</table>
</center>
<center>
<hr/>
<small>ssl 3.9<br/>
  Copyright &copy; 1991-2008
  <a href="http://www.ericsson.com/technology/opensource/erlang">Ericsson AB</a><br/>
</small>
</center></body>
</html>