public static List<X509Certificate> extractX509CertChainFromKeyInfo(
			KeyInfo keyInfo) {
		List<X509Certificate> chain = new ArrayList<X509Certificate>();

		List<?> keyInfoContent = keyInfo.getContent();
		for (Object o : keyInfoContent) {
			if (o instanceof X509Data) {
				X509Data x509Data = (X509Data) o;
				List<?> x509DataContent = x509Data.getContent();
				for (Object obj2 : x509DataContent) {
					if (obj2 instanceof X509Certificate) {
						chain.add((X509Certificate) obj2);
					}
				}
			}
		}

		return chain;
	}