csantanapr closed pull request #154: Support SSL for redis
URL: https://github.com/apache/incubator-openwhisk-package-cloudant/pull/154
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/Dockerfile b/Dockerfile
index 0934dac..aa9ae23 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -10,7 +10,7 @@ RUN apt-get update --fix-missing && \
   apt-get install -y curl && \
   apt-get update && \
   apt-get remove -y nodejs && \
-  curl -sL https://deb.nodesource.com/setup_6.x | bash - && \
+  curl -sL https://deb.nodesource.com/setup_8.x | bash - && \
   apt-get install -y nodejs
 
 # only package.json
diff --git a/provider/app.js b/provider/app.js
index 0cdf137..2deee1d 100644
--- a/provider/app.js
+++ b/provider/app.js
@@ -3,9 +3,9 @@
  * Service which can be configured to listen for triggers from a provider.
  * The Provider will store, invoke, and POST whisk events appropriately.
  */
+var URL = require('url').URL;
 var http = require('http');
 var express = require('express');
-var request = require('request');
 var bodyParser = require('body-parser');
 var bluebird = require('bluebird');
 var logger = require('./Logger');
@@ -25,6 +25,7 @@ app.set('port', process.env.PORT || 8080);
 // Allow invoking servers with self-signed certificates.
 process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
 
+
 // If it does not already exist, create the triggers database.  This is the 
database that will
 // store the managed triggers.
 var dbUsername = process.env.DB_USERNAME;
@@ -130,9 +131,21 @@ function createRedisClient() {
 
     return new Promise(function(resolve, reject) {
         if (redisUrl) {
+            var client;
             var redis = require('redis');
             bluebird.promisifyAll(redis.RedisClient.prototype);
-            var client = redis.createClient(redisUrl);
+            if (redisUrl.startsWith('rediss://')) {
+                // If this is a rediss: connection, we have some other steps.
+                client = redis.createClient(redisUrl, {
+                    tls: { servername: new URL(redisUrl).hostname }
+                });
+                // This will, with node-redis 2.8, emit an error:
+                // "node_redis: WARNING: You passed "rediss" as protocol 
instead of the "redis" protocol!"
+                // This is a bogus message and should be fixed in a later 
release of the package.
+            } else {
+                client = redis.createClient(redisUrl);
+            }
+
 
             client.on('connect', function () {
                 resolve(client);


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to