나는 글을 쓰기 시작한 래퍼입니다 API 를 필요로 하는 모든 요청은 be over HTTPS. 실제 it 개발 및 테스트를 하는 동안 나는 대신 요청률 apiu 싶다 내 스스로 어떤 반응을 실행하십시오 로컬에서 서버를 비꼬는 데 쓰인다.
나는 너무 인증서 생성 방법에 대한 데릭쉐퍼드와 https 를 만들려면 서버 및 요청을 보낼 수 있도록 한다.
내 서버에 구성은 다음과 같습니다.
var options = {
key: fs.readFileSync('./key.pem'),
cert: fs.readFileSync('./cert.pem')
};
https.createServer(options, function(req, res) {
res.writeHead(200);
res.end('OK\n');
}).listen(8000);
파일이 생성된 장비와 함께:
openssl genrsa 1024 > key.pem
openssl req -x509 -new -key key.pem > cert.pem
요청 및 구성은 다음과 같습니다.
var options = {
host: 'localhost',
port: 8000,
path: '/api/v1/test'
};
https.request(options, function(res) {
res.pipe(process.stdout);
}).end();
저도 대체하십시오 설정 'Error: 그래서 depth_zero_self_signed_cert ',' ca request 에 대한 '옵션을 추가해야 할 것 같아요.
그래서 내 질문은 제가 어떻게 알겠어요 발령합니다 다음과 같습니다.
나는 몇 가지 있지만 자체 서명됩니다 can& openssl 과 인증서 생성 정보 읽을 것, t # 39 랩 머리는요 주위에 있는 키 및 인증서를 사용할 수 있는 와그림 아웃해야 내 노드입니다 코드입니다.
대신 설정값으로 filemover api 는 CA 인증서를 사용할 수 있습니다. 그 다음 코드를 사용하여 작동됨 인증서, 이 것이 로칼에서 재현할 수 있도록 하고 싶습니다.
var ca = fs.readFileSync('./certificate.pem');
var options = {
host: 'example.com',
path: '/api/v1/test',
ca: ca
};
options.agent = new https.Agent(options);
https.request(options, function(res) {
res.pipe(process.stdout);
}).end();
실제 인증서를 또는 아니하였으매 작업을 진행할 수 더 좋아? 이러한 모든 것을 고려해 본 적이 있습니까?
(참고: # 39 의 let& 피쳐도 암호화합니다 실행하십시오. 인증서를 private network)
https://coolaj86.com/articles/how-to-create-a-csr-for-https-tls-ssl-rsa-pems/
https://github.com/coolaj86/nodejs-self-signed-certificate-example
예를 들어 '로카리오스트롬그린록스도맹 사용하여' (it 포인트 (127.0.0.1):
'use strict';
var https = require('https')
, port = process.argv[2] || 8043
, fs = require('fs')
, path = require('path')
, server
, options
;
require('ssl-root-cas')
.inject()
.addFile(path.join(__dirname, 'server', 'my-private-root-ca.cert.pem'))
;
options = {
// this is ONLY the PRIVATE KEY
key: fs.readFileSync(path.join(__dirname, 'server', 'privkey.pem'))
// You DO NOT specify `ca`, that's only for peer authentication
//, ca: [ fs.readFileSync(path.join(__dirname, 'server', 'my-private-root-ca.cert.pem'))]
// This should contain both cert.pem AND chain.pem (in that order)
, cert: fs.readFileSync(path.join(__dirname, 'server', 'fullchain.pem'))
};
function app(req, res) {
res.setHeader('Content-Type', 'text/plain');
res.end('Hello, encrypted world!');
}
server = https.createServer(options, app).listen(port, function () {
port = server.address().port;
console.log('Listening on https://127.0.0.1:' + port);
console.log('Listening on https://' + server.address().address + ':' + port);
console.log('Listening on https://localhost.greenlock.domains:' + port);
});
'use strict';
var https = require('https')
, fs = require('fs')
, path = require('path')
, ca = fs.readFileSync(path.join(__dirname, 'client', 'my-private-root-ca.cert.pem'))
, port = process.argv[2] || 8043
, hostname = process.argv[3] || 'localhost.greenlock.domains'
;
var options = {
host: hostname
, port: port
, path: '/'
, ca: ca
};
options.agent = new https.Agent(options);
https.request(options, function(res) {
res.pipe(process.stdout);
}).end();
그리고 스크립트입니다 인증서 파일을 만듭니다.
#!/bin/bash
FQDN=$1
# make directories to work from
mkdir -p server/ client/ all/
# Create your very own Root Certificate Authority
openssl genrsa \
-out all/my-private-root-ca.privkey.pem \
2048
# Self-sign your Root Certificate Authority
# Since this is private, the details can be as bogus as you like
openssl req \
-x509 \
-new \
-nodes \
-key all/my-private-root-ca.privkey.pem \
-days 1024 \
-out all/my-private-root-ca.cert.pem \
-subj "/C=US/ST=Utah/L=Provo/O=ACME Signing Authority Inc/CN=example.com"
# Create a Device Certificate for each domain,
# such as example.com, *.example.com, awesome.example.com
# NOTE: You MUST match CN to the domain name or ip address you want to use
openssl genrsa \
-out all/privkey.pem \
2048
# Create a request from your Device, which your Root CA will sign
openssl req -new \
-key all/privkey.pem \
-out all/csr.pem \
-subj "/C=US/ST=Utah/L=Provo/O=ACME Tech Inc/CN=${FQDN}"
# Sign the request from Device with your Root CA
openssl x509 \
-req -in all/csr.pem \
-CA all/my-private-root-ca.cert.pem \
-CAkey all/my-private-root-ca.privkey.pem \
-CAcreateserial \
-out all/cert.pem \
-days 500
# Put things in their proper place
rsync -a all/{privkey,cert}.pem server/
cat all/cert.pem > server/fullchain.pem # we have no intermediates in this case
rsync -a all/my-private-root-ca.cert.pem server/
rsync -a all/my-private-root-ca.cert.pem client/
# create DER format crt for iOS Mobile Safari, etc
openssl x509 -outform der -in all/my-private-root-ca.cert.pem -out client/my-private-root-ca.crt
예를 들면 다음과 같습니다.
bash make-certs.sh 'localhost.greenlock.domains'
이렇게 하면 한 관에 누워 있는 네일 여기있을 기대해 본다.
그리고 좀 더 설명: https://github.com/coolaj86/node-ssl-root-cas/wiki/Painless-Self-Signed-Certificates-in-node.js
Ca 는 루트 인증서 DER 형식을 통해 사본을 만드는 데 필요한 리스트 확장명은:
# create DER format crt for iOS Mobile Safari, etc
openssl x509 -outform der -in all/my-private-root-ca.cert.pem -out client/my-private-root-ca.crt
그 후 해당 파일을 웹 서버 경배하되 사용하면 됩니다. 이 링크를 클릭하면 인증서를 설치할 것인지 확인해야 합니다.
어떻게 이런 예는 MIT& # 39 의 인증기관 설치 작품을 볼 수 있습니다. <, https://ca.mit.edu/mitca.crt>.
추가 시도하시겠습니까
agent: false,
rejectUnauthorized: false
이 절차는 & 인증 기관 모두 만들 수 있습니다. 인증서:
wget https://raw.githubusercontent.com/anders94/https-authorized-clients/master/keys/ca.cnf ''
'- - - - - - 9999 구성용 카지케노프 키우스 ca-key.pem openssl 필요 x509 아웃해야 ca-cert.pem' 새 일
openssl 헨리사 크리스 프레마 아웃해야 4096 '-'
wget https://raw.githubusercontent.com/anders94/https-authorized-clients/master/keys/server.cnf ''
openssl 필요 - - - - 키 크리스 프레마 아웃해야 구성용 세르베리치노프 치리펨 '새'
이는 http://competitivehelp 6.을 (를)
'필요 - - - - 지나가고, 999 일 세르베리치노프 에스트피레 openssl x509 " pass:password". - - - - - CA 의 치리펨 ca-cert.pem 스키 ca-key.pem 카크리트리올 아웃해야 세르지피 주마 '
여기서요 내가 찾은 이 절차를 함께 사용 방법에 대한 자세한 내용은 해당 인증서를.