Details
-
Bug
-
Resolution: Incomplete
-
Major
-
None
-
None
-
None
-
None
Description
The certpath seems to be quite different from the previous version. It seems that the certpath needs to be a directing containing pem files, and the pem files must have the name given in the cluster.bucket(...) call (which would normally be the bucketname, but it doesn't seem to matter, as long as the pem file with that name exists)
connecting-ssl.js
// Require Couchbase Module
var couchbase = require('couchbase');
// Require Couchbase Module
var couchbase = require('couchbase');
/*
- Put Self-Signed Cluster Certificate from the cluster
- $ curl http://localhost:8091/pools/default/certificate -o /tmp/junk.pem
*/
// Setup Cluster Connection Object - must include the bucket name
// incorrect bucket name here will get you BUCKET_NOT_FOUND
var connString = 'couchbases://127.0.0.1/travel-sample?certpath=/tmp';
// Setup Cluster Connection Object
const options = {username: 'Administrator', password: 'password'};
{timeout:10}
var cluster = new couchbase.Cluster(connString,options);
// Setup Bucket object to be reused within the code
//
// specify bucket again. Actually this does appear to be used for the
// name of the bucket. It must be the name of the pem file withing
// the certpath directory.
// Mess that up and you will get a generic SSL ERROR
//
const bucket = cluster.bucket("junk.pem"); // specify bucket (again)
const collection = bucket.defaultCollection();
const docKey='airport_1254';
try {
res= collection.get(docKey,,
{ if(res)console.log("================== res: "+JSON.stringify(res)); if(err)console.log("================== err: "+err); }
(err,res)=>).catch((e)=>
{done=true; console.log(e)});
{ e.printStackTrace(); }
}catch(e)console.log(" ***************** press control-c to exit ***************");
{'Content-Type': 'text/plain'}
var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200,);
res.write('Hello World!');
res.end();
}).listen(8080);