node js 에서 ssl 적용 하는 방법
const options = { key: fs.readFileSync(‘server-key.pem’), cert: fs.readFileSync(‘server-cert.pem’),**
** // This is necessary only if using client certificate authentication. requestCert: true,**
** // This is necessary only if the client uses a self-signed certificate. ca: [ fs.readFileSync(‘client-cert.pem’) ]};
const server = tls.createServer(options, (socket) => { console.log(‘server connected’, socket.authorized ? ‘authorized’ : ‘unauthorized’); socket.write(‘welcome!\n’); socket.setEncoding(‘utf8’); socket.pipe(socket); });
———=—————- tls 로 createServer 를 실행하고 options 안에 ssl 인증서 정보 넣으면 된다.