Skip to content

Commit 392e479

Browse files
committed
Document SSLSecurity class
1 parent 15198fd commit 392e479

File tree

1 file changed

+37
-1
lines changed

1 file changed

+37
-1
lines changed

Source/SocketIO/Util/SSLSecurity.swift

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,64 @@
44
//
55
// Created by Lukas Schmidt on 24.09.17.
66
//
7+
// Permission is hereby granted, free of charge, to any person obtaining a copy
8+
// of this software and associated documentation files (the "Software"), to deal
9+
// in the Software without restriction, including without limitation the rights
10+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
// copies of the Software, and to permit persons to whom the Software is
12+
// furnished to do so, subject to the following conditions:
13+
//
14+
// The above copyright notice and this permission notice shall be included in
15+
// all copies or substantial portions of the Software.
16+
//
17+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+
// THE SOFTWARE.
724

825
import Foundation
926
import Starscream
1027

11-
public class SSLSecurity: NSObject {
28+
/// A wrapper around Starscream's SSLSecurity that provides a minimal Objective-C interface.
29+
open class SSLSecurity : NSObject {
30+
/// The internal Starscream SSLSecurity.
1231
public let security: Starscream.SSLSecurity
1332

1433
init(security: Starscream.SSLSecurity) {
1534
self.security = security
1635
}
1736

37+
/// Creates a new SSLSecurity that specifies whether to use publicKeys or certificates should be used for SSL
38+
/// pinning validation
39+
///
40+
/// - parameter usePublicKeys: is to specific if the publicKeys or certificates should be used for SSL pinning
41+
/// validation
1842
@objc
1943
public convenience init(usePublicKeys: Bool = true) {
2044
let security = Starscream.SSLSecurity(usePublicKeys: usePublicKeys)
2145
self.init(security: security)
2246
}
2347

48+
49+
/// Designated init
50+
///
51+
/// - parameter certs: is the certificates or public keys to use
52+
/// - parameter usePublicKeys: is to specific if the publicKeys or certificates should be used for SSL pinning
53+
/// validation
54+
/// - returns: a representation security object to be used with
2455
public convenience init(certs: [SSLCert], usePublicKeys: Bool) {
2556
let security = Starscream.SSLSecurity(certs: certs, usePublicKeys: usePublicKeys)
2657
self.init(security: security)
2758
}
2859

60+
/// Returns whether or not the given trust is valid.
61+
///
62+
/// - parameter trust: The trust to validate.
63+
/// - parameter domain: The CN domain to validate.
64+
/// - returns: Whether or not this is valid.
2965
public func isValid(_ trust: SecTrust, domain: String?) -> Bool {
3066
return security.isValid(trust, domain: domain)
3167
}

0 commit comments

Comments
 (0)