LoginSignup
9
9

More than 5 years have passed since last update.

koaでhttpsを使う

Last updated at Posted at 2014-05-28

koaでhttpsを使う

var https = require('https');
var options = {
key: fs.readFileSync(__dirname +"/key.pem"),
cert: fs.readFileSync(__dirname +"/cert.pem")
};
https.createServer(options, app.callback()).listen(4430);

expressと違い、#callbackが必要だった。

オレオレ証明書でためすには

key.pem、cert.pemの2ファイルを用意する。

自分は昔書いたブログ記事を参考にすると作れる。

Windowsだとハマるかも

オレオレ証明書の作成をWindowsでやったら、BOM付で作られ、そのままだとエラーで怒られたので、BOMなしにして、ついでに改行コードもLFに変換したら動いた。

関連記事

9
9
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
9