问题描述
我编写了一个通过 Nifi 的 ExecuteGroovyScript 处理器运行的 groovy 脚本。它运行良好。但是,我想知道是否有办法使用 SSL 来实现这一点?
我的 unix 服务器上有 JKS Keystore 和 Truststore JKS 文件。
下面是我写的代码:
def flowFile = session.get()
def postResult=''
def url = new URL("https://xxx.xxx.xxx/sample?key=8B4B4565-313E-462D-8160-175F6F456773")
HttpURLConnection connection = (HttpURLConnection) url.openConnection()
connection.setRequestMethod("GET")
// connection.setConnectTimeout(10000)
connection.connect()
if (connection.responseCode == 200 || connection.responseCode == 201) {
flowFile = session.putAttribute(flowFile,'api_responce_code',connection.responseCode.toString())
flowFile = session.write(flowFile,{outputStream -> outputStream.write(connection.content.getBytes())} as OutputStreamCallback)
session.transfer(flowFile,REL_SUCCESS)
} else {
flowFile = session.putAttribute(flowFile,connection.responseCode.toString())
flowFile = session.putAttribute(flowFile,'api_responce_error',connection.getErrorStream().toString())
session.transfer(flowFile,REL_FAILURE)
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)