Kendinden İmzalı SSL Sertifika Üretmek (Self Signed Certificate)
2 min readMay 31, 2020
Köşeli parantezler içinde ini dosyalarındaki gibi blok olarak anahtar değer ikilileri tutabiliyorsunuz.
Köşeli parantez içindeki isim, değişken adı gibi başka satırlarda @degisken_adi olarak çağırılabiliniyor.
Bir sertifikanın içinde geçecek bilgileri distinguished_name içinde tanımlıyoruz.
Geçerli olması istenilen alan adlarını subjectAltName içinde DNS, doğrudan IP ile geçerli olacaksa SSL sertifika IP bilgisinde yazacağız.
openssl.cnf
[req]
distinguished_name = req_distinguished_name
req_extensions = v3_req
[req_distinguished_name]
countryName = TR
countryName_default = TR
stateOrProvinceName = Istanbul
stateOrProvinceName_default = Istanbul
localityName = Colombo
localityName_default = Colombo
organizationalUnitName = IT
organizationalUnitName_default = IT
commonName = *.local
commonName_max = 64
[ v3_req ]
# Extensions to add to a certificate request
basicConstraints = CA:FALSE
keyUsage = nonRepudiation, digitalSignature, keyEncipherment
subjectAltName = @alt_names
[alt_names]
DNS.1 = *.local
DNS.2 = *.nrf.local
DNS.3 = local
IP.1 = 127.0.0.1
IP.2 = 192.168.56.1
generate.sh
#!/bin/sh
openssl req -x509 -out localhost.crt -keyout localhost.key -newkey rsa:2048 -nodes -sha256 -subj /CN=local -extensions v3_req -config openssl.cnf
Sertifikaları çalıştırdığımız web uygulaması:
const https = require('https');
const fs = require('fs');const options = {
key: fs.readFileSync('localhost.key'),
cert: fs.readFileSync('localhost.crt')
};let cl = https.createServer(options, function (req, res) {
res.writeHead(200);
res.end("hello world\n");
})
cl.on('error',console.error)
cl.listen(8000);