Created on 04-11-2016 09:30 PM
An HTTPS endpoint for receiving data in NiFi requires two processors and two controller services: HandleHttpRequest, HandleHttpResponse, SSLContextService, and HttpContextMap.
Note: The HandleHttpRequest processor in NiFi 0.6 does not have functional client authentication, but a fix will be implemented in the next version (see NIFI-1753).
SSL Context Service
HTTP Context Map
HandleHttpRequest
HandleHttpResponse
Sample Client
//Set up SSL properties System.setProperty("javax.net.ssl.trustStoreType","jks"); System.setProperty("javax.net.ssl.trustStore","agent_truststore.ts"); System.setProperty("javax.net.ssl.trustStorePassword","hadoop"); //System.setProperty("javax.net.debug","ssl"); //Verbose SSL logging //Uncomment for client authentication //System.setProperty("javax.net.ssl.keyStoreType","jks"); //System.setProperty("javax.net.ssl.keyStore","agent_keystore.jks"); //System.setProperty("javax.net.ssl.keyStorePassword","hadoop"); //Set up connectionSSLSocketFactorysslsocketfactory = (SSLSocketFactory) SSLSocketFactory.getDefault(); URLurl = new URL("https://"+NiFiHostname+":"+port); HttpsURLConnectionconn = (HttpsURLConnection)url.openConnection(); conn.setSSLSocketFactory(sslsocketfactory); // Send POST conn.setRequestMethod("POST"); conn.setReadTimeout(5000); conn.setConnectTimeout(5000); //Note: In NiFi HTTP headers are added as attributes with the following pattern: //http.headers.{headerName} conn.setRequestProperty("attr1","value"); conn.setDoOutput(true); DataOutputStream wr = new DataOutputStream(conn.getOutputStream()); wr.writeBytes("test123"); wr.flush(); wr.close(); //Get Response Code intcode = conn.getResponseCode(); System.out.println(code); conn.disconnect();
User | Count |
---|---|
758 | |
379 | |
316 | |
309 | |
270 |