1
제목은 매우 간단합니다. 회사의 웹 서비스를 사용하려고하는데 .cer 및 .p12 파일이 있습니다. 필자는 요청할 때 .p12를 사용해야합니다. 저는 .cer을 Windows로 가져 왔습니다. 우편 배달부와 쉽게 요청할 수 있습니다. 그러나 node.js로 요청을하려고 할 때 오류가 발생합니다. 인증서 인 경우.p12 인증서가있는 웹 서비스에 대한 Nodej의 요청
'use strict';
const request = require('request');
const fs = require('fs');
var options = {
url: 'https://some-url/api',
headers: {
"content-type": "application/json",
},
agentOptions: {
pfx: fs.readFileSync(__dirname + '/certs/myCert.p12'),
passphrase: ''
}
};
request.get(options, (error, response, body) => {
console.log(error);
console.log(response);
console.log(body);
});
:
{ Error: error:0906D06C:PEM routines:PEM_read_bio:no start line
at Object.createSecureContext (_tls_common.js:89:17)
at Object.exports.connect (_tls_wrap.js:1048:48)
at Agent.createConnection (https.js:111:22)
at Agent.createSocket (_http_agent.js:224:26)
at Agent.addRequest (_http_agent.js:192:10)
at new ClientRequest (_http_client.js:256:16)
at Object.request (http.js:39:10)
at Object.request (https.js:239:15)
at Request.start (D:\parser\node_modules\request\request.js:748:32)
at Request.end (D:\parser\node_modules\request\request.js:1512:10)
opensslErrorStack:
[ 'error:140DC009:SSL routines:SSL_CTX_use_certificate_chain_file:PEM lib' ] }
tha nks,이 문제를 해결 종류 않았다. 아직도 작동하지 않았고,이 버전을 두 번 전에 시도했지만 잘못된 비밀번호가 있다고 생각했습니다. 어쨌든 올바른 접근 방식을 지적 해 주셔서 감사합니다. 그래서 다른 조합을 시도하는 대신 다른 것에 집중할 수 있습니다! – uglycode