MQTTClient
an Objective-C Framework for MQTT
|
#import <MQTTSSLSecurityPolicy.h>
Instance Methods | |
Evaluating Server Trust | |
(BOOL) | - evaluateServerTrust:forDomain: |
Class Methods | |
Getting Specific Security Policies | |
(instancetype) | + defaultPolicy |
Initialization | |
(instancetype) | + policyWithPinningMode: |
Properties | |
MQTTSSLPinningMode | SSLPinningMode |
BOOL | validatesCertificateChain |
NSArray * | pinnedCertificates |
BOOL | allowInvalidCertificates |
BOOL | validatesDomainName |
MQTTSSLSecurityPolicy
evaluates server trust against pinned X.509 certificates and public keys over secure connections.
If your app using security model which require pinning SSL certificates to helps prevent man-in-the-middle attacks and other vulnerabilities. you need to set securityPolicy to properly value(see MQTTSSLSecurityPolicy.h for more detail).
NOTE: about self-signed server certificates: if your server using Self-signed certificates to establish SSL/TLS connection, you need to set property: MQTTSSLSecurityPolicy.allowInvalidCertificates=YES.
If SSL is enabled, by default it only evaluate server's certificates using CA infrastructure, and for most case, this type of check is enough. However, if your app using security model which require pinning SSL certificates to helps prevent man-in-the-middle attacks and other vulnerabilities. you may need to set securityPolicy to properly value(see MQTTSSLSecurityPolicy.h for more detail).
NOTE: about self-signed server certificates: In CA infrastructure, you may establish a SSL/TLS connection with server which using self-signed certificates by install the certificates into OS keychain(either programmatically or manually). however, this method has some disadvantages:
If you only want to verify the cert for the socket you are creating and for no other sockets in your app, you need to use MQTTSSLSecurityPolicy. And if you use self-signed server certificates, your need to set property: MQTTSSLSecurityPolicy.allowInvalidCertificates=YES
Adding pinned SSL certificates to your app helps prevent man-in-the-middle attacks and other vulnerabilities. Applications dealing with sensitive customer data or financial information are strongly encouraged to route all communication over an SSL/TLS connection with SSL pinning configured and enabled.
+ (instancetype) defaultPolicy |
Returns the shared default security policy, which does not allow invalid certificates, validates domain name, and does not validate against pinned certificates or public keys.
- (BOOL) evaluateServerTrust: | (SecTrustRef) | serverTrust | |
forDomain: | (NSString *) | domain | |
Whether or not the specified server trust should be accepted, based on the security policy.
This method should be used when responding to an authentication challenge from a server.
serverTrust | The X.509 certificate trust of the server. |
domain | The domain of serverTrust. If nil , the domain will not be validated. |
+ (instancetype) policyWithPinningMode: | (MQTTSSLPinningMode) | pinningMode |
Creates and returns a security policy with the specified pinning mode.
pinningMode | The SSL pinning mode. |
|
readwritenonatomicassign |
Whether or not to trust servers with an invalid or expired SSL certificates. Defaults to NO
. Note: If your server-certificates are self signed, your should set this property to 'YES'.
|
readwritenonatomicstrong |
The certificates used to evaluate server trust according to the SSL pinning mode. By default, this property is set to any (.cer
) certificates included in the app bundle. Note: Array item type: NSData - Bytes of X.509 certificate file in der format. Note that if you create an array with duplicate certificates, the duplicate certificates will be removed.
|
readnonatomicassign |
The criteria by which server trust should be evaluated against the pinned SSL certificates. Defaults to MQTTSSLPinningMode
.
|
readwritenonatomicassign |
Whether to evaluate an entire SSL certificate chain, or just the leaf certificate. Defaults to YES
.
|
readwritenonatomicassign |
Whether or not to validate the domain name in the certificate's CN field. Defaults to YES
.