try {
X509Certificate[] samlCertChain = this.getCertificateChain();
Document oDoc = new DocumentImpl();
KeyInfo oKeyInfo = new KeyInfo(oDoc);
X509Data oData = new X509Data(oDoc);
oData.addCertificate(samlCertChain[samlCertChain.length - 1]);
oKeyInfo.add(oData);
this.samlKeyInfo = DOMUtils.toString(oKeyInfo.getElement(), false, true);