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

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 03f4472..87d6a86 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 9ba5f98..afd880d 100755
--- a/provider/app.js
+++ b/provider/app.js
@@ -3,6 +3,7 @@
  * 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 bodyParser = require('body-parser');
@@ -129,9 +130,20 @@ 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