Get X509 Certificate expiry date from string data
===

I am trying to get expiry date of x509 certificate from xml file under tag 

    <ds:X509Certificate> MBaAFI7JTi5oRslwv2B3MmERGbPKKUsSMFwGA1UdIARVMFMwUQYKKwYBBAEJFQEBADBDMEEGCCsG
    AQUFBwIBFjVodHRwOi8vd3d3LmNpc2NvLmNvbS9zZWN1cml0eS9wa2kvcG9saWNpZXMvaW5kZXgu
    aHRtbDATBgNVHSUEDDAKBggrBgEFBQcDATANBgkqhkiG9w0BAQUFAAOCAQEAs2DJZwgVLmZqQS2N
    3Yp4iGYhZBG6vZSDaiaAg6u1wgrfq/byBd7H3Ei+V9I7MZ1aCh4s3kl6FJ1CoRhMQcM1gbxpCbPP
    KAfrMv/5/MH8erMnole7m/MqVHETX1UbLEyagOioqK3cs8MzMKxC+Fdku6Bm+i/6xhUsc6XbrVJl
    IHsVBB9+9ZnpjAjC9jj21r04N51cyfp6C37999TaybNEtCJlG0XTHfLbcyX65E9ndVaRd6GYu/d0
    xW0MT5bKhA36KhpUROAbPS7rXKKkfCYnMkmImE7Hfvm3vRSahX+ehY1Tx9qJXFv3PYGzbyDbvpjV
    2cSUgP/bhGATKSOZuhohrw==  </ds:X509Certificate

>

I have code that reads it to a string 

    NodeList nodelist = element.getElementsByTagName("ds:X509Certificate");
    Element element1 = (Element) nodelist.item(0);
    NodeList certificateItem = element1.getChildNodes();
    String certificateValue = "---- BEGIN CERTIFICATE -------- " + "\n" +
    "certificateItem.item(0).getNodeValue()" + "\n" + "--- END CERTIFICATE";                            
    System.out.print("Certificate data is : " + certificateValue);
    InputStream certinputstream = new ByteArrayInputStream(certificateValue.getBytes());
    CertificateFactory cf = CertificateFactory.getInstance("X.509");
    X509Certificate cert = (X509Certificate)cf.generateCertificate(certinputstream);
    System.out.println("Expiry Date : " + cert.getNotAfter());

But I am getting the following error
java.security.cert.CertificateParsingException: invalid DER-encoded certificate data
	at sun.security.x509.X509CertImpl.parse(Unknown Source)
	at sun.security.x509.X509CertImpl.<init>(Unknown Source)
Any ideas ? Thanks