Support Questions
Find answers, ask questions, and share your expertise

Nifi xml parsing when SSL is enabled.

Nifi xml parsing when SSL is enabled.


I'm trying to write a java program that takes the XML file generated by a nifi-api url and generates an email if the queue size of the nifi flow exceeds a certain threshold. But the problem is that since SSL is enabled, the XML file is not being accessed and it gives me the below error: Unexpected end of file from server at at at at at at at at ReadXMLFile.main(

When I manually try to access the link I had to select a certificate and I think that is the problem in accessing the XML file from code. Can someone tell me how to sign or select a certificate through java code?

My Program:

import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.DocumentBuilder;
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
import org.w3c.dom.Node;
import org.w3c.dom.Element;

public class ReadXMLFile {
  public static void main(String argv[]) {
    try {
	URL url = new URL("");

	DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();

	DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();

	InputStream stream = url.openStream();

	Document doc = dBuilder.parse(stream);

	System.out.println("Root element :" + doc.getDocumentElement().getNodeName());
	NodeList nList = doc.getElementsByTagName("processGroupStatus");
	for (int temp = 0; temp < nList.getLength(); temp++) {
		Node nNode = nList.item(temp);
		System.out.println("\nCurrent Element :" + nNode.getNodeName());
		if (nNode.getNodeType() == Node.ELEMENT_NODE) {

			Element eElement = (Element) nNode;

			int lastElement = eElement.getElementsByTagName("queuedSize").getLength() -1;

			System.out.println("queuedSize : " + eElement.getElementsByTagName("queuedSize").item(lastElement).getTextContent());

			System.out.println("queuedCount : " + eElement.getElementsByTagName("queuedCount").item(lastElement).getTextContent());



    } catch (Exception e) {






Re: Nifi xml parsing when SSL is enabled.

If you are using client certificates as an authentication mechanism, you will need to provide a valid client certificate in the Java invocation of the API. You can do this by loading a Java Keystore (*.jks) file containing the private key of the client certificate and presenting that. An example of the code to do so (using Apache httpclient and JRE variables) is here. You can also do this explicitly by writing code to parse an arbitrary keystore and load a key via SSLContext and SSLSockets (see here).