fix(node-vsphere-soap): better handling of self signed cert

This commit is contained in:
Florent BEAUCHAMP
2023-06-09 10:03:25 +02:00
committed by Julien Fontanet
parent af562f3c3a
commit d68f4215f1
3 changed files with 13 additions and 8 deletions

View File

@@ -13,11 +13,12 @@
*/
const EventEmitter = require('events').EventEmitter
const axios = require('axios')
const https = require('node:https')
const util = require('util')
const soap = require('soap')
const Cookie = require('soap-cookie') // required for session persistence
const { SSL_OP_NO_TLSv1_2 } = require('crypto').constants
const constants = require('crypto').constants
// Client class
// inherits from EventEmitter
// possible events: connect, error, ready
@@ -35,11 +36,14 @@ function Client(vCenterHostname, username, password, sslVerify) {
this.clientopts = {}
} else {
this.clientopts = {
rejectUnauthorized: false,
strictSSL: false,
secureOptions: SSL_OP_NO_TLSv1_2, // likely needed for node >= 10.0
} // recommended options by node-soap authors
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0' // need for self-signed certs
request: axios.create({
httpsAgent: new https.Agent({
rejectUnauthorized: false,
secureOptions: constants.SSL_OP_NO_TLSv1_2, // likely needed for node >= 10.0
}),
}),
}
}
this.connectionInfo = {

View File

@@ -11,6 +11,7 @@
},
"bugs": "https://github.com/vatesfr/xen-orchestra/issues",
"dependencies": {
"axios": "^1.4.0",
"soap": "^1.0.0",
"soap-cookie": "^0.10.1"
},