回答編集履歴
4
大丈夫!
answer
CHANGED
@@ -23,7 +23,7 @@
|
|
23
23
|
}
|
24
24
|
```
|
25
25
|
|
26
|
-
## Swift 3.x (ビルドも動作も
|
26
|
+
## Swift 3.x (ビルドも動作も大丈夫らしい)
|
27
27
|
|
28
28
|
```swift
|
29
29
|
var trust: SecTrust?
|
3
SecTrustRef -> SecTrust
answer
CHANGED
@@ -26,7 +26,7 @@
|
|
26
26
|
## Swift 3.x (ビルドも動作も未確認)
|
27
27
|
|
28
28
|
```swift
|
29
|
-
var trust:
|
29
|
+
var trust: SecTrust?
|
30
30
|
var result: SecTrustResultType = .invalid
|
31
31
|
|
32
32
|
let cert = SecCertificateCreateWithData(kCFAllocatorDefault, certData)
|
2
UnsafeMutablePointerを使わない
answer
CHANGED
@@ -6,3 +6,33 @@
|
|
6
6
|
|
7
7
|
[SecCertificateCreateWithData(_:_:)](https://developer.apple.com/reference/security/1396073-seccertificatecreatewithdata)
|
8
8
|
[SecTrustCreateWithCertificates(_:_:_:)](https://developer.apple.com/reference/security/1401555-sectrustcreatewithcertificates)
|
9
|
+
|
10
|
+
# UnsafeMutablePointerを使わない
|
11
|
+
|
12
|
+
## Swift 2.3 (ビルドだけ確認、動作未確認)
|
13
|
+
|
14
|
+
```swift
|
15
|
+
var trust: SecTrustRef?
|
16
|
+
var result: SecTrustResultType = SecTrustResultType(kSecTrustResultInvalid)
|
17
|
+
|
18
|
+
let cert = SecCertificateCreateWithData(kCFAllocatorDefault, certData)
|
19
|
+
SecTrustCreateWithCertificates(cert!, SecPolicyCreateBasicX509(), &trust)
|
20
|
+
SecTrustEvaluate(trust!, &result)
|
21
|
+
if (result != SecTrustResultType(kSecTrustResultUnspecified) && result != SecTrustResultType(kSecTrustResultProceed)) {
|
22
|
+
print("Invalid certificate")
|
23
|
+
}
|
24
|
+
```
|
25
|
+
|
26
|
+
## Swift 3.x (ビルドも動作も未確認)
|
27
|
+
|
28
|
+
```swift
|
29
|
+
var trust: SecTrustRef?
|
30
|
+
var result: SecTrustResultType = .invalid
|
31
|
+
|
32
|
+
let cert = SecCertificateCreateWithData(kCFAllocatorDefault, certData)
|
33
|
+
SecTrustCreateWithCertificates(cert!, SecPolicyCreateBasicX509(), &trust)
|
34
|
+
SecTrustEvaluate(trust!, &result)
|
35
|
+
if (result != .unspecified && result != .proceed) {
|
36
|
+
print("Invalid certificate")
|
37
|
+
}
|
38
|
+
```
|
1
URL
answer
CHANGED
@@ -2,4 +2,7 @@
|
|
2
2
|
|
3
3
|
> Call the CFRelease function to release this object when you are finished with it.
|
4
4
|
|
5
|
-
と、ドキュメントに書かれています。
|
5
|
+
と、ドキュメントに書かれています。
|
6
|
+
|
7
|
+
[SecCertificateCreateWithData(_:_:)](https://developer.apple.com/reference/security/1396073-seccertificatecreatewithdata)
|
8
|
+
[SecTrustCreateWithCertificates(_:_:_:)](https://developer.apple.com/reference/security/1401555-sectrustcreatewithcertificates)
|