Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

i meet https error? use portal bind Self-signed certificate? #289

Closed
liujunyi opened this issue Aug 20, 2018 · 4 comments
Closed

i meet https error? use portal bind Self-signed certificate? #289

liujunyi opened this issue Aug 20, 2018 · 4 comments

Comments

@liujunyi
Copy link

liujunyi commented Aug 20, 2018

error:
FetchError: request to https://[server]/portal/sharing/rest/search failed, reason: unable to verify the first certificate

I had try cas,but it not work
require('ssl-root-cas').inject();
var rootCas = require('ssl-root-cas/latest').create();
rootCas
.addFile(__dirname + '/ssl/pem.pem')
;
require('https').globalAgent.options.ca = rootCas;

@jgravois
Copy link
Contributor

do you encounter an error/warning when you attempt to visit the portal using 'https' in the browser?

@liujunyi
Copy link
Author

liujunyi commented Aug 22, 2018

i used Self-signed certificate to my arcgis portal, I had solve it by change code,
i change @esri/arcgis-rest-request code,change request.js

fetchOptions = {
  method: httpMethod,
  agent:new https.Agent({rejectUnauthorized: false}), // ++++
  // ensures behavior mimics XMLHttpRequest. needed to support sending IWA cookies
  credentials: "same-origin"
};

@jgravois
Copy link
Contributor

nice work.

@b00tsy
Copy link

b00tsy commented Apr 29, 2022

I'm facing the same problem here with 4.x but the proposed solution seems to require overriding request.js, which kind of is making using the whole library obsolete.

From comments around other issues (unfortunately browsed thru too many and closed them already) I saw a comment on an issue that you're planning to allow passing fetch options from the calling method. Is that already a thing?

That's the context I need to deal with that.

const { queryFeatures } = require('@esri/arcgis-rest-feature-service')
const features = await queryFeatures({
  fetchOptions: { https: { rejectUnauthorized: true } }
})

Of course better would be to be able to define the expected ca instead of ignoring the tls validation, which I'd assume to be able to configure in such a way.

Currently I'm using raw node http libraries, where I can customize such things directly, using arcgis rest js, however, would make everything more convenient...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants