Programing

리프 서명을 확인할 수 없습니다

lottogame 2020. 7. 19. 09:49
반응형

리프 서명을 확인할 수 없습니다


node.js request.js를 사용하여 API에 도달하고 있습니다. 이 오류가 발생합니다

[오류 : UNABLE_TO_VERIFY_LEAF_SIGNATURE]

모든 자격 증명이 정확하고 유효하며 서버는 괜찮습니다. 우편 배달부와 같은 요청을했습니다.

request({
    "url": domain+"/api/orders/originator/"+id,
    "method": "GET",
    "headers":{
        "X-API-VERSION": 1,
        "X-API-KEY": key
    },
}, function(err, response, body){
    console.log(err);
    console.log(response);
    console.log(body);
});

이 코드는 실행 가능한 스크립트 ex에서 실행 중입니다. node ./run_file.js왜 그런가요? 서버에서 실행해야합니까?


참고 : 다음은 위험하므로 클라이언트와 서버간에 API 컨텐츠를 가로 채서 수정할 수 있습니다.

이것은 또한 일했다

process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = '0';


응용 프로그램에는 문제가 아니지만 중개 CA가 서명 한 인증서에 문제가 있습니다. 해당 사실을 수락하고 계속 진행하려면 다음을 추가하여 옵션을 요청하십시오.

rejectUnauthorized: false

전체 요청 :

request({
    "rejectUnauthorized": false,
    "url": domain+"/api/orders/originator/"+id,
    "method": "GET",
    "headers":{
        "X-API-VERSION": 1,
        "X-API-KEY": key
    },
}, function(err, response, body){
    console.log(err);
    console.log(response);
    console.log(body);
});

안전한 솔루션

보안을 끄는 대신 필요한 인증서를 체인에 추가 할 수 있습니다. 먼저 npm에서 ssl-root-cas 패키지를 설치하십시오 .

npm install ssl-root-cas

이 패키지에는 브라우저가 신뢰하지만 노드가 신뢰하지 않는 많은 중개 인증서가 포함되어 있습니다.

var sslRootCAs = require('ssl-root-cas/latest')
sslRootCAs.inject()

누락 된 인증서를 추가합니다. 자세한 내용은 여기를 참조하십시오.

https://git.coolaj86.com/coolaj86/ssl-root-cas.js

또한 아래의 다음 답변을 참조하십시오


CoolAJ86의 솔루션은 정확하고 그것을 사용하는 모든 검사를 비활성화처럼 보안을 손상하지 않는 rejectUnauthorizedNODE_TLS_REJECT_UNAUTHORIZED. 여전히 추가 CA 인증서를 명시 적으로 주입해야 할 수도 있습니다.

먼저 ssl-root-cas 모듈에 포함 된 루트 CA를 시도했습니다 .

require('ssl-root-cas/latest')
  .inject();

나는 여전히 UNABLE_TO_VERIFY_LEAF_SIGNATURE오류로 끝났습니다 . 그런 다음 COMODO SSL Analyzer 에서 연결 한 웹 사이트의 인증서를 누가 발급했는지 확인하고 해당 기관의 인증서를 다운로드 한 후 해당 인증서 만 추가하려고했습니다.

require('ssl-root-cas/latest')
  .addFile(__dirname + '/comodohigh-assurancesecureserverca.crt');

다른 오류가 발생했습니다 CERT_UNTRUSTED. 마지막으로 추가 루트 CA를 주입하고 "my"(명백히 중개자) CA를 포함 시켰습니다.

require('ssl-root-cas/latest')
  .inject()
  .addFile(__dirname + '/comodohigh-assurancesecureserverca.crt');

들어 만들기 앱 반응 (이 오류도 발생하고이 질문 # 1 구글 결과입니다), 당신은 아마 사용 HTTPS=true npm start하고는 proxy(에서 package.json) 개발에 일부 HTTPS API 자체 서명하는 자체 때로 이동한다.

이 경우 proxy다음과 같이 변경 하십시오.

"proxy": {
  "/api": {
    "target": "https://localhost:5001",
    "secure": false
  }
}

secure decides whether the WebPack proxy checks the certificate chain or not and disabling that ensures the API self-signed certificate is not verified so that you get your data.


Just putting this here in case it helps someone, my case was different and a bit of an odd mix. I was getting this on a request that was accessed via superagent - the problem had nothing to do with certificates (which were setup properly) and all to do with the fact that I was then passing the superagent result through the async module's waterfall callback. To fix: Instead of passing the entire result, just pass result.body through the waterfall's callback.


I had the same issues. I have followed @ThomasReggi and @CoolAJ86 solution and worked well but I'm not satisfied with the solution.

Because "UNABLE_TO_VERIFY_LEAF_SIGNATURE" issue is happened due to certification configuration level.

I accept @thirdender solution but its partial solution.As per the nginx official website, they clearly mentioned certificate should be combination of The server certificate and chained certificates.

enter image description here


It may be very tempting to do rejectUnauthorized: false or process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = '0'; but don't do it! It exposes you to man in the middle attacks.

The other answers are correct in that the issue lies in the fact that your cert is "signed by an intermediary CA." There is an easy solution to this, one which does not require a third party library like ssl-root-cas or injecting any additional CAs into node.

Most https clients in node support options that allow you to specify a CA per request, which will resolve UNABLE_TO_VERIFY_LEAF_SIGNATURE. Here's a simple example using node's built-int https module.

import https from 'https';

const options = {
  host: '<your host>',
  defaultPort: 443,
  path: '<your path>',
  // assuming the bundle file is co-located with this file
  ca: readFileSync(__dirname + '/<your bundle file>.ca-bundle'),
  headers: {
    'content-type': 'application/json',
  }
};
https.get(options, res => {
  // do whatever you need to do
})

If, however, you can configure the ssl settings in your hosting server, the best solution would be to add the intermediate certificates to your hosting provider. That way the client requester doesn't need to specify a CA, since it's included in the server itself. I personally use namecheap + heroku. The trick for me was to create one .crt file with cat yourcertificate.crt bundle.ca-bundle > server.crt. I then opened up this file and added a newline after the first certificate. You can read more at

https://www.namecheap.com/support/knowledgebase/article.aspx/10050/33/installing-an-ssl-certificate-on-heroku-ssl


I had an issue with my Apache configuration after installing a GoDaddy certificate on a subdomain. I originally thought it might be an issue with Node not sending a Server Name Indicator (SNI), but that wasn't the case. Analyzing the subdomain's SSL certificate with https://www.ssllabs.com/ssltest/ returned the error Chain issues: Incomplete.

After adding the GoDaddy provided gd_bundle-g2-g1.crt file via the SSLCertificateChainFile Apache directive, Node was able to connect over HTTPS and the error went away.


Put rejectUnauthorized: false in the petition, and that worked for me.


You have to include the Intermediate certificate in your server. This solves the [Error: UNABLE_TO_VERIFY_LEAF_SIGNATURE]

참고URL : https://stackoverflow.com/questions/20082893/unable-to-verify-leaf-signature

반응형