Javascript 当REST API服务器发出自签名证书时,如何通过https从节点API与REST API通信

Javascript 当REST API服务器发出自签名证书时,如何通过https从节点API与REST API通信,javascript,node.js,ssl,https,self-signed-certificate,Javascript,Node.js,Ssl,Https,Self Signed Certificate,我们有一个连接到基于JAVA的RESTAPI服务器的NodeJSAPI客户端。服务器发出自签名证书。目前我们设定: rejectUnauthorized: false });``` So this basically doesn’t care if the server’s identity cannot be verified. And it can’t be verified as it is self-signed and it won’t match the built-in CA’

我们有一个连接到基于JAVA的RESTAPI服务器的NodeJSAPI客户端。服务器发出自签名证书。目前我们设定:

  rejectUnauthorized: false
});```
So this basically doesn’t care if the server’s identity cannot be verified. And it can’t be verified as it is self-signed and it won’t match the built-in CA’s.

Now I have the Root CA and the intermediate certs in the key-chain. Is there any configuration I can use in Node to verify the certificate that the server returns if I have the Root CA's and relevant certs on File.

Also, do I need the intermediate certs in the Key chain for this?
I am not well versed in https and any help is appreciated.