You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by GitBox <gi...@apache.org> on 2021/07/29 08:37:47 UTC

[GitHub] [couchdb-nano] indrajit-kanjilal opened a new issue #271: Nano with Axios upgrade does not work for HTTPS based couchdb access anymore

indrajit-kanjilal opened a new issue #271:
URL: https://github.com/apache/couchdb-nano/issues/271


   <!--- Provide a general summary of the issue in the Title above -->
   
   Nano has stopped working after moving to Axios for Secure Socket connections (https).
   The following code which worked in nano@8.2.2 , does not work in current version
   
   _--------------------------------------------------------------------------------------------------------
   const Path = require('path');
   const fs = require('fs');
   const caFile = fs.readFileSync(`${Path.join(__dirname, 'secrets')}${Path.sep}cacert.crt`);
   
   const dboptions = {
       url: 'https://XXXX:YYYYYY@localhost:6984',
       requestDefaults: { 
           ca : caFile
           //rejectUnauthorized: false
       }
     }
   const nano = require('nano')(dboptions);
   //const solwbusagedb = nano.db.use('solwbusage');
   
   const start = async () => {
       try{
           await nano.db.list();
       }
       catch(err){
           console.log(err);
       }
   }
   
   start();
   ---------------------------------------------------------------------------------------------------_
   
   ## Expected Behavior
   <!--- If you're describing a bug, tell us what should happen -->
   
   If upgrade to based versions of nano needs special handling of clients
   which **requires** HTTPS based access to nano, it sahould be documented.
   
   <!--- If you're suggesting a change/improvement, tell us how it should work -->
   
   Either the code mentioned above should work as-is , or there should be a way to
   make it work, which is documented.
   
   ## Current Behavior
   <!--- If describing a bug, tell us what happens instead of the expected behavior -->
   nano@8.2.2 : **Works fine**
   
   nano@latest:
   Error: error happened in your connection
       at responseHandler (C:\..........\server\node_modules\nano\lib\nano.js:120:16)
       at C:\...........\server\node_modules\nano\lib\nano.js:405:13
       at processTicksAndRejections (internal/process/task_queues.js:97:5)
   
   <!--- If suggesting a change/improvement, explain the difference from current behavior -->
   
   ## Possible Solution
   <!--- Not obligatory, but suggest a fix/reason for the bug, -->
   <!--- or ideas how to implement the addition or change -->
   
   ## Steps to Reproduce (for bugs)
   <!--- Provide a link to a live example, or an unambiguous set of steps to -->
   
   <!--- reproduce this bug. Include code to reproduce, if relevant -->
   1. Just run the above code on a HTTPS enabled server on port 6984 with the CA certificate in "secrets" directory
   2. Run it with nano@8.2.2 installed first , and then with latest version
   3.
   4.
   
   ## Context
   <!--- How has this issue affected you? What are you trying to accomplish? -->
   I use it in one of our internal tool, and all our server policy mandates HTTPS enables ports only
   
   <!--- Providing context helps us come up with a solution that is most useful in the real world -->
   
   ## Your Environment
   <!--- Include as many relevant details about the environment you experienced the bug in -->
   * Version used: Current (9*) and 8.2.2
   * Browser Name and version:
   * Operating System and version (desktop or mobile): Windows 10, node 12.16.1
   * Link to your project: N/A
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@couchdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [couchdb-nano] sploders101 edited a comment on issue #271: Nano with Axios upgrade does not work for HTTPS based couchdb access anymore

Posted by GitBox <gi...@apache.org>.
sploders101 edited a comment on issue #271:
URL: https://github.com/apache/couchdb-nano/issues/271#issuecomment-906453838


   @indrajit-kanjilal 
   I believe that this is a configuration issue. From what I can tell, the requestDefaults are shallow-merged (can be problematic; addressed in issue #273) with the request directly before being passed to axios. According to [axios documentation](https://github.com/axios/axios#request-config), it requires an `Agent` instance:
   
   >  // `httpAgent` and `httpsAgent` define a custom agent to be used when performing http
   >  // and https requests, respectively, in node.js. This allows options to be added like
   >  // `keepAlive` that are not enabled by default.
   >  httpAgent: new http.Agent({ keepAlive: true }),
   >  httpsAgent: new https.Agent({ keepAlive: true }),
   
   Try passing your agent options into a ` new https.Agent(...)` call and move that to the `httpsAgent` property.
   Edit: It looks like they do some copying for the agent, so the `agent` property should still be valid, but you may still need to wrap it in a `new https.Agent(...)`.
   
   ---
   
   @ceras-ella
   > which is all fine, but when you'll try to create or destroy a database you end up with a circular structure error:
   
   This may be addressed by #274 and #275. I believe that error may have been caused by the logging function using a JSON-based deep clone, which doesn't work with circular references.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@couchdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [couchdb-nano] sploders101 commented on issue #271: Nano with Axios upgrade does not work for HTTPS based couchdb access anymore

Posted by GitBox <gi...@apache.org>.
sploders101 commented on issue #271:
URL: https://github.com/apache/couchdb-nano/issues/271#issuecomment-906453838


   @indrajit-kanjilal 
   I believe that this is a configuration issue. From what I can tell, the requestDefaults are shallow-merged (can be problematic; addressed in issue #273) with the request directly before being passed to axios. According to [axios documentation](https://github.com/axios/axios#request-config), it requires an `Agent` instance:
   
   >  // `httpAgent` and `httpsAgent` define a custom agent to be used when performing http
   >  // and https requests, respectively, in node.js. This allows options to be added like
   >  // `keepAlive` that are not enabled by default.
   >  httpAgent: new http.Agent({ keepAlive: true }),
   >  httpsAgent: new https.Agent({ keepAlive: true }),
   
   Try passing your agent options into a ` new https.Agent(...)` call and move that to the `httpsAgent` property.
   
   @ceras-ella
   > which is all fine, but when you'll try to create or destroy a database you end up with a circular structure error:
   
   This may be addressed by #274 and #275. I believe that error may have been caused by the logging function using a JSON-based deep clone, which doesn't work with circular references.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@couchdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [couchdb-nano] sploders101 edited a comment on issue #271: Nano with Axios upgrade does not work for HTTPS based couchdb access anymore

Posted by GitBox <gi...@apache.org>.
sploders101 edited a comment on issue #271:
URL: https://github.com/apache/couchdb-nano/issues/271#issuecomment-906453838


   @indrajit-kanjilal 
   I believe that this is a configuration issue. From what I can tell, the requestDefaults are shallow-merged (can be problematic; addressed in issue #273) with the request directly before being passed to axios. According to [axios documentation](https://github.com/axios/axios#request-config), it requires an `Agent` instance:
   
   >  // `httpAgent` and `httpsAgent` define a custom agent to be used when performing http
   >  // and https requests, respectively, in node.js. This allows options to be added like
   >  // `keepAlive` that are not enabled by default.
   >  httpAgent: new http.Agent({ keepAlive: true }),
   >  httpsAgent: new https.Agent({ keepAlive: true }),
   
   Try passing your agent options into a ` new https.Agent(...)` call and move that to the `httpsAgent` property.
   
   ---
   
   @ceras-ella
   > which is all fine, but when you'll try to create or destroy a database you end up with a circular structure error:
   
   This may be addressed by #274 and #275. I believe that error may have been caused by the logging function using a JSON-based deep clone, which doesn't work with circular references.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@couchdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [couchdb-nano] ceras-ella edited a comment on issue #271: Nano with Axios upgrade does not work for HTTPS based couchdb access anymore

Posted by GitBox <gi...@apache.org>.
ceras-ella edited a comment on issue #271:
URL: https://github.com/apache/couchdb-nano/issues/271#issuecomment-899524972


   I second this issue... Is anyone looking into it by the way?
   
   And to add more details to it:
   @indrajit-kanjilal you can list the databases using the following requestDefaults:
   ```
   requestDefaults = {
     agent: new https.Agent({
       ca : caFile
       ...
       rejectUnauthorized: true
     })
   };
   ```
   
   which is all fine, but when you'll try to `create` or `destroy` a database you end up with a circular structure error:
   ```
   TypeError: Converting circular structure to JSON
       --> starting at object with constructor 'TLSSocket'
       |     property '_httpMessage' -> object with constructor 'ClientRequest'
       --- property 'socket' closes the circle
         at JSON.stringify (<anonymous>)
         at relax (node_modules/nano/lib/nano.js:370:41)
         at Object.destroyDb [as destroy] (node_modules/nano/lib/nano.js:457:12)
   ```
   
   that I believed it's been addressed in the following PR (not sure, didn't verify that it solves this particular issue::
   https://github.com/apache/couchdb-nano/pull/270 
   
   so, any chance we can get some traction on this? we'll be reverting to version 8 until this is properly fixed.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@couchdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [couchdb-nano] glynnbird commented on issue #271: Nano with Axios upgrade does not work for HTTPS based couchdb access anymore

Posted by GitBox <gi...@apache.org>.
glynnbird commented on issue #271:
URL: https://github.com/apache/couchdb-nano/issues/271#issuecomment-911530264


   Fixed in 9.0.4


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@couchdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [couchdb-nano] glynnbird edited a comment on issue #271: Nano with Axios upgrade does not work for HTTPS based couchdb access anymore

Posted by GitBox <gi...@apache.org>.
glynnbird edited a comment on issue #271:
URL: https://github.com/apache/couchdb-nano/issues/271#issuecomment-910331206


   You are right as ever @sploders101. Nano does work for HTTPS - it works with Cloudant, for example, just fine. The problem comes when dealing with HTTPS certificate which can't be authenticated with your operating system's CA bundle. If you need to supply your own certification authority file then you'll need to create your own https agent like so:
   
   ```js
   const httpsAgent = new https.Agent({
     ca: '/path/to/cert',
     rejectUnauthorized: true
   })
   const nano = Nano({
     url: process.env.COUCH_URL,
     log: console.log,
     requestDefaults: {
       agent: httpsAgent
     }
   })
   ```
   
   The circular references bugs are now fixed on main, and will be released soon.
   
   I'll drop an example in the README, as this isn't documented anywhere.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@couchdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [couchdb-nano] glynnbird closed issue #271: Nano with Axios upgrade does not work for HTTPS based couchdb access anymore

Posted by GitBox <gi...@apache.org>.
glynnbird closed issue #271:
URL: https://github.com/apache/couchdb-nano/issues/271


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@couchdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [couchdb-nano] glynnbird commented on issue #271: Nano with Axios upgrade does not work for HTTPS based couchdb access anymore

Posted by GitBox <gi...@apache.org>.
glynnbird commented on issue #271:
URL: https://github.com/apache/couchdb-nano/issues/271#issuecomment-910331206


   You are right as ever @sploders101. Nano does work for HTTPS - it works with Cloudant, for example, just fine. The problem comes when dealing with HTTPS certificate which can't be authenticated with your operating system's CA bundle. If you need to supply your own certification authority file then you'll need to create your own https agent like so:
   
   ```js
   const httpsAgent = new https.Agent({
     ca: '/path/to/cert',
     rejectUnauthorized: true
   })
   const nano = Nano({
     url: process.env.COUCH_URL,
     log: console.log,
     requestDefaults: {
       agent: httpsAgent
     }
   })
   ```
   
   The circular references bugs are now fixed on main, and will be released soon.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@couchdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [couchdb-nano] ceras-ella commented on issue #271: Nano with Axios upgrade does not work for HTTPS based couchdb access anymore

Posted by GitBox <gi...@apache.org>.
ceras-ella commented on issue #271:
URL: https://github.com/apache/couchdb-nano/issues/271#issuecomment-899524972


   I second this issue... Is anyone looking into it by the way?
   
   And to add more details to it:
   @indrajit-kanjilal you can list the databases using the following requestDefaults:
   ```
   requestDefaults = {
     agent: new https.Agent({
       ca : caFile
       ...
       rejectUnauthorized: true
     })
   };
   ```
   
   which is all fine, but when you'll try to `create` or `destroy` a database you end up with a circular structure error that I believed it's been addressed in the following PR:
   https://github.com/apache/couchdb-nano/pull/270 
   
   so, any chance we can get some traction on this? we'll be reverting to version 8 until this is properly fixed.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@couchdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org