Example usage for java.security.cert X509Certificate hasUnsupportedCriticalExtension

List of usage examples for java.security.cert X509Certificate hasUnsupportedCriticalExtension

Introduction

In this page you can find the example usage for java.security.cert X509Certificate hasUnsupportedCriticalExtension.

Prototype

public boolean hasUnsupportedCriticalExtension();

Source Link

Document

Check if there is a critical extension that is not supported.

Usage

From source file:com.sk89q.mclauncher.security.X509KeyStore.java

/**
 * Check if a server certificate chain is trusted.
 *///from w w  w .ja v  a2  s.  c  o  m
@Override
public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {
    for (X509Certificate cert : chain) {
        cert.checkValidity();
        if (cert.hasUnsupportedCriticalExtension()) {
            throw new CertificateException("Unsupported critical extension found");
        }
    }

    try {
        verify(chain);
    } catch (CertificateVerificationException e) {
        throw new CertificateException("Verification error: " + e.getMessage(), e);
    } catch (CertPathBuilderException e) {
        throw new CertificateException(e.getMessage(), e);
    }
}