回答編集履歴

4

大丈夫!

2017/03/31 02:14

投稿

fuzzball
fuzzball

スコア16731

test CHANGED
@@ -48,7 +48,7 @@
48
48
 
49
49
 
50
50
 
51
- ## Swift 3.x (ビルドも動作も未確認)
51
+ ## Swift 3.x (ビルドも動作も大丈夫らしい)
52
52
 
53
53
 
54
54
 

3

SecTrustRef -> SecTrust

2017/03/31 02:14

投稿

fuzzball
fuzzball

スコア16731

test CHANGED
@@ -54,7 +54,7 @@
54
54
 
55
55
  ```swift
56
56
 
57
- var trust: SecTrustRef?
57
+ var trust: SecTrust?
58
58
 
59
59
  var result: SecTrustResultType = .invalid
60
60
 

2

UnsafeMutablePointerを使わない

2017/03/31 02:10

投稿

fuzzball
fuzzball

スコア16731

test CHANGED
@@ -15,3 +15,63 @@
15
15
  [Sec​Trust​Create​With​Certificates(_:​_:​_:​)](https://developer.apple.com/reference/security/1401555-sectrustcreatewithcertificates)
16
16
 
17
17
 
18
+
19
+ # UnsafeMutablePointerを使わない
20
+
21
+
22
+
23
+ ## Swift 2.3 (ビルドだけ確認、動作未確認)
24
+
25
+
26
+
27
+ ```swift
28
+
29
+ var trust: SecTrustRef?
30
+
31
+ var result: SecTrustResultType = SecTrustResultType(kSecTrustResultInvalid)
32
+
33
+
34
+
35
+ let cert = SecCertificateCreateWithData(kCFAllocatorDefault, certData)
36
+
37
+ SecTrustCreateWithCertificates(cert!, SecPolicyCreateBasicX509(), &trust)
38
+
39
+ SecTrustEvaluate(trust!, &result)
40
+
41
+ if (result != SecTrustResultType(kSecTrustResultUnspecified) && result != SecTrustResultType(kSecTrustResultProceed)) {
42
+
43
+ print("Invalid certificate")
44
+
45
+ }
46
+
47
+ ```
48
+
49
+
50
+
51
+ ## Swift 3.x (ビルドも動作も未確認)
52
+
53
+
54
+
55
+ ```swift
56
+
57
+ var trust: SecTrustRef?
58
+
59
+ var result: SecTrustResultType = .invalid
60
+
61
+
62
+
63
+ let cert = SecCertificateCreateWithData(kCFAllocatorDefault, certData)
64
+
65
+ SecTrustCreateWithCertificates(cert!, SecPolicyCreateBasicX509(), &trust)
66
+
67
+ SecTrustEvaluate(trust!, &result)
68
+
69
+ if (result != .unspecified && result != .proceed) {
70
+
71
+ print("Invalid certificate")
72
+
73
+ }
74
+
75
+ ```
76
+
77
+

1

URL

2017/03/31 00:46

投稿

fuzzball
fuzzball

スコア16731

test CHANGED
@@ -7,3 +7,11 @@
7
7
 
8
8
 
9
9
  と、ドキュメントに書かれています。
10
+
11
+
12
+
13
+ [Sec​Certificate​Create​With​Data(_:​_:​)](https://developer.apple.com/reference/security/1396073-seccertificatecreatewithdata)
14
+
15
+ [Sec​Trust​Create​With​Certificates(_:​_:​_:​)](https://developer.apple.com/reference/security/1401555-sectrustcreatewithcertificates)
16
+
17
+