14
14
15
15
import SwiftASN1
16
16
17
- extension Certificate . Extensions {
18
- /// Provides details on how to access information about the certificate issuer.
19
- ///
20
- /// This extension behaves as a collection of ``Certificate/Extensions-swift.struct/AuthorityInformationAccess-swift.struct/AccessDescription`` objects.
17
+ /// Provides details on how to access information about the certificate issuer.
18
+ ///
19
+ /// This extension behaves as a collection of ``AuthorityInformationAccess/AccessDescription`` objects.
20
+ ///
21
+ /// In practice this most commonly contains OCSP servers and links to the issuing CA certificate.
22
+ public struct AuthorityInformationAccess {
23
+ @usableFromInline
24
+ var descriptions : [ AccessDescription ]
25
+
26
+ /// Create a new ``AuthorityInformationAccess/`` object
27
+ /// containing specific access descriptions.
21
28
///
22
- /// In practice this most commonly contains OCSP servers and links to the issuing CA certificate.
23
- public struct AuthorityInformationAccess {
24
- @usableFromInline
25
- var descriptions : [ AccessDescription ]
29
+ /// - Parameter descriptions: The descriptions to include in the AIA extension.
30
+ @inlinable
31
+ public init < Descriptions: Sequence > ( _ descriptions: Descriptions ) where Descriptions. Element == AccessDescription {
32
+ self . descriptions = Array ( descriptions)
33
+ }
26
34
27
- /// Create a new ``Certificate/Extensions-swift.struct/AuthorityInformationAccess-swift.struct/`` object
28
- /// containing specific access descriptions.
29
- ///
30
- /// - Parameter descriptions: The descriptions to include in the AIA extension.
31
- @inlinable
32
- public init < Descriptions: Sequence > ( _ descriptions: Descriptions ) where Descriptions. Element == AccessDescription {
33
- self . descriptions = Array ( descriptions)
35
+ /// Create a new ``AuthorityInformationAccess`` object
36
+ /// by unwrapping a ``Certificate/Extension``.
37
+ ///
38
+ /// - Parameter ext: The ``Certificate/Extension`` to unwrap
39
+ /// - Throws: if the ``Certificate/Extension/oid`` is not equal to
40
+ /// `ASN1ObjectIdentifier.X509ExtensionID.authorityInformationAccess`.
41
+ @inlinable
42
+ public init ( _ ext: Certificate . Extension ) throws {
43
+ guard ext. oid == . X509ExtensionID. authorityInformationAccess else {
44
+ throw CertificateError . incorrectOIDForExtension ( reason: " Expected \( ASN1ObjectIdentifier . X509ExtensionID. authorityInformationAccess) , got \( ext. oid) " )
34
45
}
35
46
36
- /// Create a new ``Certificate/Extensions-swift.struct/AuthorityInformationAccess-swift.struct`` object
37
- /// by unwrapping a ``Certificate/Extension``.
38
- ///
39
- /// - Parameter ext: The ``Certificate/Extension`` to unwrap
40
- /// - Throws: if the ``Certificate/Extension/oid`` is not equal to
41
- /// `ASN1ObjectIdentifier.X509ExtensionID.authorityInformationAccess`.
42
- @inlinable
43
- public init ( _ ext: Certificate . Extension ) throws {
44
- guard ext. oid == . X509ExtensionID. authorityInformationAccess else {
45
- throw CertificateError . incorrectOIDForExtension ( reason: " Expected \( ASN1ObjectIdentifier . X509ExtensionID. authorityInformationAccess) , got \( ext. oid) " )
46
- }
47
-
48
- let aiaSyntax = try AuthorityInfoAccessSyntax ( derEncoded: ext. value)
49
- self . descriptions = aiaSyntax. descriptions. map { AccessDescription ( $0) }
50
- }
47
+ let aiaSyntax = try AuthorityInfoAccessSyntax ( derEncoded: ext. value)
48
+ self . descriptions = aiaSyntax. descriptions. map { AccessDescription ( $0) }
51
49
}
52
50
}
53
51
54
- extension Certificate . Extensions . AuthorityInformationAccess : Hashable { }
52
+ extension AuthorityInformationAccess : Hashable { }
55
53
56
- extension Certificate . Extensions . AuthorityInformationAccess : Sendable { }
54
+ extension AuthorityInformationAccess : Sendable { }
57
55
58
- extension Certificate . Extensions . AuthorityInformationAccess : CustomStringConvertible {
56
+ extension AuthorityInformationAccess : CustomStringConvertible {
59
57
public var description : String {
60
58
return self . map { String ( describing: $0) } . joined ( separator: " , " )
61
59
}
62
60
}
63
61
64
62
// TODO(cory): Probably also RangeReplaceableCollection, even though it's kinda crap.
65
- extension Certificate . Extensions . AuthorityInformationAccess : RandomAccessCollection {
63
+ extension AuthorityInformationAccess : RandomAccessCollection {
66
64
@inlinable
67
65
public var startIndex : Int {
68
66
self . descriptions. startIndex
@@ -85,7 +83,7 @@ extension Certificate.Extensions.AuthorityInformationAccess: RandomAccessCollect
85
83
}
86
84
}
87
85
88
- extension Certificate . Extensions . AuthorityInformationAccess {
86
+ extension AuthorityInformationAccess {
89
87
/// Describes the location and format of additional information provided
90
88
/// by the issuer of a given certificate.
91
89
public struct AccessDescription {
@@ -95,7 +93,7 @@ extension Certificate.Extensions.AuthorityInformationAccess {
95
93
/// The location where the information may be found.
96
94
public var location : GeneralName
97
95
98
- /// Construct a new ``Certificate/Extensions-swift.struct/ AuthorityInformationAccess-swift.struct /AccessDescription`` from constituent parts.
96
+ /// Construct a new ``AuthorityInformationAccess/AccessDescription`` from constituent parts.
99
97
@inlinable
100
98
public init ( method: AccessMethod , location: GeneralName ) {
101
99
self . method = method
@@ -110,19 +108,19 @@ extension Certificate.Extensions.AuthorityInformationAccess {
110
108
}
111
109
}
112
110
113
- extension Certificate . Extensions . AuthorityInformationAccess . AccessDescription : Hashable { }
111
+ extension AuthorityInformationAccess . AccessDescription : Hashable { }
114
112
115
- extension Certificate . Extensions . AuthorityInformationAccess . AccessDescription : Sendable { }
113
+ extension AuthorityInformationAccess . AccessDescription : Sendable { }
116
114
117
- extension Certificate . Extensions . AuthorityInformationAccess . AccessDescription : CustomStringConvertible {
115
+ extension AuthorityInformationAccess . AccessDescription : CustomStringConvertible {
118
116
public var description : String {
119
117
return " \( self . method) : \( self . location) "
120
118
}
121
119
}
122
120
123
- extension Certificate . Extensions . AuthorityInformationAccess . AccessDescription {
121
+ extension AuthorityInformationAccess . AccessDescription {
124
122
/// The format and meaning of the information included in a single
125
- /// ``Certificate/Extensions-swift.struct/ AuthorityInformationAccess-swift.struct /AccessDescription``
123
+ /// ``AuthorityInformationAccess/AccessDescription``
126
124
/// object.
127
125
public struct AccessMethod {
128
126
@usableFromInline
@@ -160,11 +158,11 @@ extension Certificate.Extensions.AuthorityInformationAccess.AccessDescription {
160
158
}
161
159
}
162
160
163
- extension Certificate . Extensions . AuthorityInformationAccess . AccessDescription . AccessMethod : Hashable { }
161
+ extension AuthorityInformationAccess . AccessDescription . AccessMethod : Hashable { }
164
162
165
- extension Certificate . Extensions . AuthorityInformationAccess . AccessDescription . AccessMethod : Sendable { }
163
+ extension AuthorityInformationAccess . AccessDescription . AccessMethod : Sendable { }
166
164
167
- extension Certificate . Extensions . AuthorityInformationAccess . AccessDescription . AccessMethod : CustomStringConvertible {
165
+ extension AuthorityInformationAccess . AccessDescription . AccessMethod : CustomStringConvertible {
168
166
@inlinable
169
167
public var description : String {
170
168
switch self . backing {
@@ -178,9 +176,9 @@ extension Certificate.Extensions.AuthorityInformationAccess.AccessDescription.Ac
178
176
}
179
177
}
180
178
181
- extension Certificate . Extensions . AuthorityInformationAccess . AccessDescription . AccessMethod . Backing : Hashable { }
179
+ extension AuthorityInformationAccess . AccessDescription . AccessMethod . Backing : Hashable { }
182
180
183
- extension Certificate . Extensions . AuthorityInformationAccess . AccessDescription . AccessMethod . Backing : Sendable { }
181
+ extension AuthorityInformationAccess . AccessDescription . AccessMethod . Backing : Sendable { }
184
182
185
183
extension Certificate . Extension {
186
184
/// Construct an opaque ``Certificate/Extension`` from this AIA extension.
@@ -189,15 +187,15 @@ extension Certificate.Extension {
189
187
/// - aia: The extension to wrap
190
188
/// - critical: Whether this extension should have the critical bit set.
191
189
@inlinable
192
- public init ( _ aia: Certificate . Extensions . AuthorityInformationAccess , critical: Bool ) throws {
190
+ public init ( _ aia: AuthorityInformationAccess , critical: Bool ) throws {
193
191
let asn1Representation = AuthorityInfoAccessSyntax ( aia)
194
192
var serializer = DER . Serializer ( )
195
193
try serializer. serialize ( asn1Representation)
196
194
self . init ( oid: . X509ExtensionID. authorityInformationAccess, critical: critical, value: serializer. serializedBytes [ ... ] )
197
195
}
198
196
}
199
197
200
- extension Certificate . Extensions . AuthorityInformationAccess : CertificateExtensionConvertible {
198
+ extension AuthorityInformationAccess : CertificateExtensionConvertible {
201
199
public func makeCertificateExtension( ) throws -> Certificate . Extension {
202
200
return try . init( self , critical: false )
203
201
}
@@ -222,7 +220,7 @@ struct AuthorityInfoAccessSyntax: DERImplicitlyTaggable {
222
220
var descriptions : [ AIAAccessDescription ]
223
221
224
222
@inlinable
225
- init ( _ aia: Certificate . Extensions . AuthorityInformationAccess ) {
223
+ init ( _ aia: AuthorityInformationAccess ) {
226
224
self . descriptions = aia. descriptions. map { . init( $0) }
227
225
}
228
226
@@ -261,7 +259,7 @@ struct AIAAccessDescription: DERImplicitlyTaggable {
261
259
}
262
260
263
261
@inlinable
264
- init ( _ description: Certificate . Extensions . AuthorityInformationAccess . AccessDescription ) {
262
+ init ( _ description: AuthorityInformationAccess . AccessDescription ) {
265
263
self . accessMethod = ASN1ObjectIdentifier ( accessMethod: description. method)
266
264
self . accessLocation = description. location
267
265
}
@@ -295,7 +293,7 @@ extension ASN1ObjectIdentifier {
295
293
}
296
294
297
295
@inlinable
298
- public init ( accessMethod: Certificate . Extensions . AuthorityInformationAccess . AccessDescription . AccessMethod ) {
296
+ public init ( accessMethod: AuthorityInformationAccess . AccessDescription . AccessMethod ) {
299
297
switch accessMethod. backing {
300
298
case . ocspServer:
301
299
self = . AccessMethodIdentifiers. ocspServer
0 commit comments