README.mdwn

MemorizingTrustManager - Private Cloud Support for Your App

MemorizingTrustManager (MTM) is a project to enable smarter and more secure use
of SSL on Android. If it encounters an unknown SSL certificate, it asks the
user whether to accept the certificate once, permanently or to abort the
connection. This is a step in preventing man-in-the-middle attacks by blindly
accepting any invalid, self-signed and/or expired certificates.

MTM is aimed at providing seamless integration into your Android application,
and the source code is available under the MIT license.

Screenshots

Status

MemorizingTrustManager is in production use in the
yaxim XMPP client. It is usable and easy to integrate,
though it does not yet support hostname validation (the Java API makes it
hard to integrate).

Integration

MTM is easy to integrate into your own application. Follow these steps or have
a look into the demo application in the example directory.

By default, MTM falls back to the system TrustManager before asking the user.
If you do not trust the establishment, you can enforce a dialog on every new
connection by supplying a defaultTrustManager = null parameter to the
constructor:

MemorizingTrustManager mtm = new MemorizingTrustManager(this, null);

If you want to use a different underlying TrustManager, like
AndroidPinning, just supply that to
MTM's constructor:

4. Profit!

Logging

MTM uses java.util.logging (JUL) for logging purposes. If you have not
configured a Handler for JUL, then Android will by default log all
messages of Level.INFO or higher. In order to get also the debug log
messages (those with Level.FINE or lower) you need to configure a
Handler accordingly. The MTM example project contains
de.duenndns.mtmexample.JULHandler, which allows to enable and disable
debug logging at runtime.

Alternatives

MemorizingTrustManager is not the only one out there.

NetCipher is an Android
library made by the Guardian Project to
improve network security for mobile apps. It comes with a StrongTrustManager
to do more thorough certificate checks, an independent Root CA store, and code
to easily route your traffic through
the Tor network using Orbot.

AndroidPinning is another Android
library, written by Moxie Marlinspike to allow
pinning of server certificates, improving security against government-scale
MitM attacks. Use this if your app is made to communicate with a specific
server!