try {
X509Data x509Data = keyInfo.itemX509Data(x509DataItemIdx);
if (false == x509Data.containsCertificate()) {
continue;
}
int certificateCount = x509Data.lengthCertificate();
for (int certificateIdx = 0; certificateIdx < certificateCount; certificateIdx++) {
XMLX509Certificate xmlX509Certificate = x509Data.itemCertificate(certificateIdx);
X509Certificate certificate = xmlX509Certificate.getX509Certificate();
certificateChain.add(certificate);
}