SSL Error making callback from NodeJS target

We are making a REST call to some external HTTPS URLs from within the NodeJS target. However, when we try to make the call, the NodeJS application errors out and it restarts. In the MP logs we see the error titled "Could not generate DH keypair" immediately before the app.js restarts. Now the question is, is there something that we need to do to have the NodeJS make the calls to HTTPS services? When we issue a curl command to the URL from within the MP it seems to work fine. However from within Node we run into the error situation. Do we need to upload certificates or get trireme to recognize some certificates on the keystore? This is an OPDK installation.
1 6 789
6 REPLIES 6

Not applicable
Hi @Prashanth Subrahmanyam , You may want to check this https://www.npmjs.com/package/trireme#tls-ssl-and-... Have a look at #4 .

Thanks a lot man, I'll try this out.

Not applicable
It's hard to tell what the error could be without more information. Do you have any other error messages other than "Could not generate DH keypair?" Is there any code that we can try? There was a TLS handshake problem that we fixed in issue APIRT-1496. That fix has been deployed to our cloud, so it'd be interesting to see if your app works correctly in the Apigee cloud.

Hey @Greg We are running this on a OPDK instance. I do not know what the version is, but need to check. I will try a simple callout on both the OPDK and Cloud and will compare notes. The solution we have on the customer is a large NodeJS application, so it is nothing that we can try to run easily. We are making a node request.post() callout to a HTTPS service on the same TLD, and immediately after the callout, we see the below error trace on the MP logs.
2015-09-01 14:01:39,318 org:Vodafone env:staging Trireme: Vodafone__staging__NotificationsEnablerInternalProcessor__app.js INFO  NODE_SCRIPT_OUTPUT - LogOutputStream.output() : 
2015-09-01 14:01:39,318 org:Vodafone env:staging Trireme: Vodafone__staging__NotificationsEnablerInternalProcessor__app.js ERROR NODE_SCRIPT_OUTPUT - LogOutputStream.output() : 
2015-09-01 14:01:39,319 org:Vodafone env:staging Trireme: Vodafone__staging__NotificationsEnablerInternalProcessor__app.js ERROR NODESCRIPT - NodeScriptInstance$Lsnr.onComplete() : Application: NotificationsEnablerInternalProcessor: Script app.js exited with status code -1: java.lang.RuntimeException: Could not generate DH keypair
2015-09-01 14:01:39,319 org:Vodafone env:staging Trireme: Vodafone__staging__NotificationsEnablerInternalProcessor__app.js ERROR NODE_SCRIPT_OUTPUT - LogOutputStream.output() : *** Script app.js exited with status code -1: java.lang.RuntimeException: Could not generate DH keypair
2015-09-01 14:01:39,319 org:Vodafone env:staging Trireme: Vodafone__staging__NotificationsEnablerInternalProcessor__app.js INFO  MESSAGING.CONFIGURATION - ScriptManager.scheduleRestart() : Scheduling restart of script node://app.js in 2 seconds
2015-09-01 14:01:39,608 org:Vodafone env:staging NIOThread@1 INFO  MESSAGING.FLOW - SyncExecutionStrategy.execute() : SyncExecution failed unexpectedly with message : Raising fault. Fault name : AssignHomeDocumentResponse
2015-09-01 14:01:39,614 org:Vodafone env:staging NIOThread@1 ERROR ADAPTORS.HTTP.FLOW - ResponseWriteListener.onException() : ResponseWriteListener.onException(HTTPResponse@4d66b5b9, null)
2015-09-01 14:01:39,615 org:Vodafone env:staging NIOThread@1 ERROR HTTP.SERVER - HTTPServer$Context$2.onException() : Message id:ip-172-26-64-70.eu-de1.plex-dc.vodafone.com_BTsDkAmw_RouterProxy-2-9833437_3 ClientOutputChannel(ClientChannel[A:172.26.67.212:8998 Remote host:172.26.64.70:55465]@27259).onExceptionWrite exception:java.lang.NullPointerException
2015-09-01 14:01:39,615 org:Vodafone env:staging NIOThread@1 INFO  HTTP.SERVICE - ExceptionHandler.handleException() : Exception java.lang.NullPointerException occurred while writing to channel ClientOutputChannel(ClientChannel[A:172.26.67.212:8998 Remote host:172.26.64.70:55465]@27259)
2015-09-01 14:01:39,616 org:Vodafone env:staging NIOThread@1 INFO  HTTP.SERVICE - ExceptionHandler.handleException() : Exception trace: 
java.lang.NullPointerException: null
	at com.apigee.messaging.adaptors.http.flow.execution.ResponseWriteListener.onFinish(ResponseWriteListener.java:98) ~[http-adaptor-1.0.0.jar:na]
	at com.apigee.protocol.http.HTTPServer$Context$2.onFinish(HTTPServer.java:627) [http-1.0.0.jar:na]
	at com.apigee.protocol.http.io.MessageWriter.finished(MessageWriter.java:195) [http-1.0.0.jar:na]
	at com.apigee.protocol.http.io.MessageWriter.finished(MessageWriter.java:200) [http-1.0.0.jar:na]
	at com.apigee.protocol.http.io.BodyPipe.closeOutput(BodyPipe.java:188) [http-1.0.0.jar:na]
	at com.apigee.protocol.http.io.BodyPipe.onWrite(BodyPipe.java:117) [http-1.0.0.jar:na]
	at com.apigee.protocol.http.io.BodyPipe.start(BodyPipe.java:90) [http-1.0.0.jar:na]
	at com.apigee.protocol.http.io.MessageWriter.onWrite(MessageWriter.java:158) [http-1.0.0.jar:na]
	at com.apigee.protocol.http.io.MessageWriter.<init>(MessageWriter.java:107) [http-1.0.0.jar:na]
	at com.apigee.protocol.http.HTTPServer$Context$2.<init>(HTTPServer.java:603) [http-1.0.0.jar:na]
	at com.apigee.protocol.http.HTTPServer$Context.send(HTTPServer.java:603) [http-1.0.0.jar:na]
	at com.apigee.messaging.adaptors.http.configuration.MessageProcessorHttpSkeletonFactory$FlowCompletionListener.onFinish(MessageProcessorHttpSkeletonFactory.java:318) [http-adaptor-1.0.0.jar:na]
	at com.apigee.flow.MessageFlowImpl.onCompletion(MessageFlowImpl.java:192) [message-flow-1.0.0.jar:na]
	at com.apigee.flow.MessageFlowImpl.resume(MessageFlowImpl.java:154) [message-flow-1.0.0.jar:na]
	at com.apigee.flow.execution.ExecutionContextImpl$1.run(ExecutionContextImpl.java:92) [message-flow-1.0.0.jar:na]
	at com.apigee.nio.NIOSelector.runTasks(NIOSelector.java:299) [nio-1.0.0.jar:na]
	at com.apigee.nio.NIOSelector.access$000(NIOSelector.java:27) [nio-1.0.0.jar:na]
	at com.apigee.nio.NIOSelector$2.findNext(NIOSelector.java:247) [nio-1.0.0.jar:na]
	at com.apigee.nio.NIOSelector$2.findNext(NIOSelector.java:238) [nio-1.0.0.jar:na]
	at com.apigee.nio.util.NonNullIterator.computeNext(NonNullIterator.java:16) [nio-1.0.0.jar:na]
	at com.apigee.nio.util.AbstractIterator.hasNext(AbstractIterator.java:36) [nio-1.0.0.jar:na]
	at com.apigee.nio.handlers.NIOThread.run(NIOThread.java:59) [nio-1.0.0.jar:na]
2015-09-01 14:01:40,984 org:Vodafone env:staging Trireme: Vodafone__staging__NotificationsEnablerCampaigns__app.js INFO  NODE_SCRIPT_OUTPUT - LogOutputStream.output() : curl -X PUT http://xxxxxfone.com:13808/AppServices/mplusdev2/... -d '"{\"pn-messangerplus-status\" : \"notification_displayed\"}"'
2015-09-01 14:01:41,320 org:Vodafone env:staging Apigee-Timer-7 INFO  NODESCRIPT - NodeScriptInstance.startScript() : App NotificationsEnablerInternalProcessor starting script app.js
2015-09-01 14:01:41,320 org:Vodafone env:staging Apigee-Timer-7 ERROR NODE_SCRIPT_OUTPUT - LogOutputStream.output() : *** Starting script

Not applicable
Hi Greg, Prashanth, we've faced similar issue with error:"Unable to generate DH keypair" Testcase: on-premises installation of Apigee EDGE 4.15.01 java version "1.6.0_45" Java(TM) SE Runtime Environment (build 1.6.0_45-b06) Java HotSpot(TM) 64-Bit Server VM (build 20.45-b01, mixed mode) we've created a dummy API with only cors policy to call backend and download a file. When we point it to a backend with SSL cert TLS_RSA_WITH_AES_128_CBC_SHA it wokrs. but when we point it to a backend with cert: TLS_DHE_RSA_WITH_AES_256_CBC_SHA we get the error. See attached trace. There's a known bug in Java 1.6 when trying to do SSL hanshake with stronger cyphers. http://bugs.java.com/bugdatabase/view_bug.do?bug_id=7044060 Can we safely upgrade java to 1.7 for EDGE 4.15.01? I believe this should solve the issue. BR, Plamen

Not applicable

I can't think of any reason why you shouldn't be able to try your use case with Java 7. However it'd make sense to check with Support just to ensure that it is supported for the specific version that you are on.