Use certificate pinning to help prevent man-in-the-middle attacks.
When communicating over public networks it is essential to send and receive information securely. The protocol widely used to secure these communications is SSL/TLS. (SSL/TLS refers to Secure Sockets Layer or to its successor, TLS, or Transport Layer Security.) SSL/TLS uses digital certificates to provide authentication and encryption. To trust that a certificate is genuine and valid, it is digitally signed by a root certificate belonging to a trusted certificate authority (CA). Operating systems and browsers maintain lists of trusted CA root certificates so that they can easily verify certificates that the CAs have issued and signed.
Protocols that rely on certificate chain verification, such as SSL/TLS, are vulnerable to a number of dangerous attacks, including man-in-the-middle attacks, which occur when an unauthorized party is able to view and modify all traffic passing between the mobile device and the backend systems.
IBM MobileFirst™ Platform Foundation provides an API to enable certificate pinning. This API is supported in native iOS, native Android, and cross-platform Cordova MobileFirst applications.
If pinning is successful, the public key inside the provided certificate is used to verify the integrity of the MobileFirst Server certificate during the secured request SSL/TLS handshake. If pinning fails, all SSL/TLS requests to the server are rejected by the client application.
You must use a certificate purchased from a certificate authority. Self-signed certificates are not supported. For compatibility with the supported environments, make sure to use a certificate that is encoded in DER (Distinguished Encoding Rules, as defined in the International Telecommunications Union X.690 standard) format.
You must place the certificate in both the MobileFirst Server and in your application. Place the certificate as follows:
Certificate pinning consists of a single API method, that has a parameter certificateFilename, where certificateFilename is the name of the certificate file.
public void pinTrustedCertificatePublicKey(String certificateFilename) throws IllegalArgumentException
WLClient.getInstance().pinTrustedCertificatePublicKey("myCertificate.cer");
pinTrustedCertificatePublicKeyFromFile:(NSString*) certificateFilename;
[[WLClient sharedInstance]pinTrustedCertificatePublicKeyFromFile:@"myCertificate.cer"];
WL.Client.pinTrustedCertificatePublicKey('certificateFilename').then(onSuccess,onFailure)
WL.Client.pinTrustedCertificatePublicKey('myCertificate.cer').then(onSuccess,onFailure)
Later, if a secured request is made to a server whose certificate is not pinned, the onFailure callback of the specific request (for example, WL.Client.connect or WLResourceRequest) is called.