commit | author | age
|
2370e0
|
1 |
// |
H |
2 |
// MQTTCFSocketTransport.h |
|
3 |
// MQTTClient |
|
4 |
// |
|
5 |
// Created by Christoph Krey on 06.12.15. |
|
6 |
// Copyright © 2015-2016 Christoph Krey. All rights reserved. |
|
7 |
// |
|
8 |
|
|
9 |
#import "MQTTTransport.h" |
|
10 |
#import "MQTTCFSocketDecoder.h" |
|
11 |
#import "MQTTCFSocketEncoder.h" |
|
12 |
|
|
13 |
/** MQTTCFSocketTransport |
|
14 |
* implements an MQTTTransport on top of CFNetwork |
|
15 |
*/ |
|
16 |
@interface MQTTCFSocketTransport : MQTTTransport <MQTTTransport, MQTTCFSocketDecoderDelegate, MQTTCFSocketEncoderDelegate> |
|
17 |
|
|
18 |
/** host an NSString containing the hostName or IP address of the host to connect to |
|
19 |
* defaults to @"localhost" |
|
20 |
*/ |
|
21 |
@property (strong, nonatomic) NSString *host; |
|
22 |
|
|
23 |
/** port an unsigned 16 bit integer containing the IP port number to connect to |
|
24 |
* defaults to 1883 |
|
25 |
*/ |
|
26 |
@property (nonatomic) UInt16 port; |
|
27 |
|
|
28 |
/** tls a boolean indicating whether the transport should be using security |
|
29 |
* defaults to NO |
|
30 |
*/ |
|
31 |
@property (nonatomic) BOOL tls; |
|
32 |
|
|
33 |
/** certificates An identity certificate used to reply to a server requiring client certificates according |
|
34 |
* to the description given for SSLSetCertificate(). You may build the certificates array yourself or use the |
|
35 |
* sundry method clientCertFromP12. |
|
36 |
*/ |
|
37 |
@property (strong, nonatomic) NSArray *certificates; |
|
38 |
|
|
39 |
/** reads the content of a PKCS12 file and converts it to an certificates array for initWith... |
|
40 |
@param path the path to a PKCS12 file |
|
41 |
@param passphrase the passphrase to unlock the PKCS12 file |
|
42 |
@returns a certificates array or nil if an error occured |
|
43 |
|
|
44 |
@code |
|
45 |
NSString *path = [[NSBundle bundleForClass:[MQTTClientTests class]] pathForResource:@"filename" |
|
46 |
ofType:@"p12"]; |
|
47 |
|
|
48 |
NSArray *myCerts = [MQTTCFSocketTransport clientCertsFromP12:path passphrase:@"passphrase"]; |
|
49 |
if (myCerts) { |
|
50 |
|
|
51 |
self.session = [[MQTTSession alloc] init]; |
|
52 |
... |
|
53 |
self.session.certificates = myCerts; |
|
54 |
|
|
55 |
[self.session connect]; |
|
56 |
... |
|
57 |
} |
|
58 |
|
|
59 |
@endcode |
|
60 |
|
|
61 |
*/ |
|
62 |
|
|
63 |
+ (NSArray *)clientCertsFromP12:(NSString *)path passphrase:(NSString *)passphrase; |
|
64 |
|
|
65 |
@end |