Some time ago, I pitched the idea of implementing certificate/pubkey pinning in our apps. Altho the idea was well received, I wanted to come with better data to understand the implications of this implementation.

What is TLS pinning ?

Overview

When a client talk to a server, it use TLS to cipher and authentify the connection with the server. The authentification (making sure you are talking to the server you intend to speak to), is done by the server presenting a certificate to the client.

What is a certificate?

Image for post
Image for post

To summary, a certificate contains:

  • A public key (used by the client to cypher the data sent to the server)
  • Some optional fields about the organization that owns the certificate (company name, location…

Consider this code (description bellow):

Image for post
Image for post
  1. We initialize an array of random data
  2. In the first benchmark, we sum its higher than average numbers
  3. We sort the array
  4. We run the same benchmark again.

Sounds simple right ?

However, the results can be a little bit unexpected:

  • 0.03 sec for the first one
  • 0.01 sec for the second one

What’s going on here ?

If you can read a title, you probably know what’s going on:

Branch predictions.

Steve Jobs once tried to explain what is branch prediction:

“I don’t know what it does. It predicts branches”

“It’s a good thing”

Steve jobs, 2003

Thank you Steve !

I’m not sure if this was enough, so I’ll try to explain a bit…


Illustration

Image for post
Image for post

Motivations

VS the default `UIImagePickerController `

`UIImagePickerController` is great, and comes with some advantages (reduced code size, no permissions needed), but comes with some serious flaw, such as limited integrations, no customisations, and no multi assets picking.

VS a third party library

While there a (a lot) of Assets Picker libraries that offer very good alternatives, we wanted to go a bit further:
- Let you (optionally) write your own view controllers using our MVVM architecture
- Customisable header cell
- Streamlined, background download of cloud assets
- Dynamically reloading the collections when the user update them

Where are we using it:

How does it works:

Client side:

Simply create the view controller and setup the…

About

Antoine Marandon

French software engineer working in Tokyo

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store