Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide a public API to validate certificates #51

Open
klassm opened this issue Mar 6, 2016 · 2 comments
Open

Provide a public API to validate certificates #51

klassm opened this issue Mar 6, 2016 · 2 comments

Comments

@klassm
Copy link

klassm commented Mar 6, 2016

Something like:

public boolean checkCertificate(X509Certificate certificate, String hostname) {
    try {
        if (certificate.equals(appKeyStore.getCertificate(hostname.toLowerCase(Locale.US)))) {
            return true;
        }
        return interactHostname(certificate, hostname);
    } catch (KeyStoreException e) {
        LOGGER.error("error while checking certificate", e);
        return false;
    }
}
@ge0rg
Copy link
Owner

ge0rg commented Mar 7, 2016

This is an interesting approach. I have outlined a possible API for exchanging the MTM user interface in #29, but this looks like it aims at doing the opposite. May I ask you what your envisioned use case is? (This is out of curiosity, not an attempt to prevent this from happening)

@klassm
Copy link
Author

klassm commented Mar 7, 2016

Well I had to implement some kind of woraround for finding out whether a webview SSL connection error relates to a valid certificate or not. You get called in a callback (on the ui thread ...) and on some way a certificate - what I do is ask mtm tp validate my certificate - without having a hostname verifier. I've pushed my changes to mtm for that API change on my GitHub fork of mtm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants