Written by: Mio Kanzaki(Security Analyst (AI))Reviewed by: 千葉圭介Updated
Certificate pinning is a method by which an app fixes in advance the certificate it trusts. OWASP's sheet describes it as a way of tying a destination server to the certificate or public key that the server is supposed to present. When you hold several candidates, the set of pinned information is called a pin set.
How does certificate pinning work?
Receiving a parcel is a good comparison. Normally you accept it after looking at the courier's uniform and ID. Pinning is a way of deciding in advance the face and name: you accept only from this courier of this company. A different person who is merely wearing the uniform gets no parcel.
An ordinary app accepts communication if the certificate is signed by a body on the list of certificate authorities the device trusts. According to OWASP's sheet, if a fraudulent certificate is issued by an authority on that list, or a malicious authority is installed on the device, the communication may be intercepted midway. Pinning narrows what is accepted to only the certificates or keys you decided, and reduces that danger.
But the fixed information must be updated together with the swapping of certificates on the server side. If you replace only the certificate without updating the app, the app can no longer connect even to the correct server.
The overall picture of communication safety is set out on the page on insecure communication. For checking what is visible from outside, the free URL check is the entry point.
Why does certificate pinning matter?
An operator who owns an app may be asked by the developer whether to add pinning. The answer in OWASP's sheet is that it should not be considered in most cases. The reason is that the danger of failure tends to be greater than the safety gained.
What OWASP's sheet allows is the case where both the destination and the app are under your control and the fixed information can be updated safely. Being able to know the certificates or keys before you begin to use them is also a condition. It applies only to native smartphone apps. The mechanism for browsers called HPKP was deprecated in browsers by 2019, OWASP's explanation writes.
Tips for using it are also in the sheet. Pin the end-entity certificate, hold backup pin information with it, and do not create an option that lets users skip a failure. Writing your own verification code is not recommended because mistakes creep in. In an environment with a mechanism that relays company traffic, the sheet says not to allow that mechanism as an exception, and only where a decision to accept the risk was made to add the relay's public key to the pin information.
To decide whether pinning fits your app, contact us.
Related terms
- SSL/TLS certificate: an electronic certificate that shows a site is genuine
- Certificate authority (CA): a trusted third-party body that issues certificates
- Man-in-the-middle attack: an attack that cuts into the middle of communication
- PKI (public key infrastructure): the whole mechanism that supports issuing and managing certificates
Frequently asked questions
Should our smartphone app use pinning?
OWASP's sheet says it should not be considered in most cases. It becomes an option only when both the destination and the app are under your control and you can safely redistribute the app in step with certificate renewals. Decide after you and your developer settle the update procedure.
What happens if I renew the certificate after adding pinning?
If the certificate no longer matches what was fixed, the app cannot connect. OWASP's sheet says that when app updates cannot keep pace with certificate renewals, it becomes a failure in which communication stops. One approach is to prepare backup pin information.
Next step
Whether to add pinning is decided together with how the app is updated. Starting with a review of insecure communication keeps the order right. The free URL check shows only what is visible from outside, and for app communication design, contact us.
Frequently asked questions
Should our smartphone app use pinning?
OWASP's sheet says it should not be considered in most cases. It becomes an option only when both the destination and the app are under your control and you can safely redistribute the app in step with certificate renewals. Decide after you and your developer settle the update procedure.
What happens if I renew the certificate after adding pinning?
If the certificate no longer matches what was fixed, the app cannot connect. OWASP's sheet says that when app updates cannot keep pace with certificate renewals, it becomes a failure in which communication stops. One approach is to prepare backup pin information.