Setup (https) SSL on localhost for meteor development

后端 未结 3 1779
暖寄归人
暖寄归人 2021-02-01 06:50

How do you create a self signed SSL certificate to use on local server on mac 10.9?

I require my localhost serving as https://localhost

I am using t

3条回答
  •  时光取名叫无心
    2021-02-01 07:01

    Quick and easy solution that works in dev/prod mode, using http-proxy ontop of your app.

    1) Add in the tarang:ssl package

    meteor add tarang:ssl
    

    2) Add your certificate and key to a directory in your app /private, e.g /private/key.pem and /private/cert.pem

    Then in your /server code

    Meteor.startup(function() {
        SSLProxy({
           port: 6000, //or 443 (normal port/requires sudo)
           ssl : {
                key: Assets.getText("key.pem"),
                cert: Assets.getText("cert.pem"),
    
                //Optional CA
                //Assets.getText("ca.pem")
           }
        });
    });
    

    Then fire up your app and load up https://localhost:6000. Be sure not to mix up your ports with https and http as they are served seperately.

    With this I'm assuming you know how to create your own self signed certificate, there are loads of resources on how to do this. Just in case here are some links.

    • http://www.akadia.com/services/ssh_test_certificate.html
    • https://devcenter.heroku.com/articles/ssl-certificate-self

    An alternative to self signed certs: it may be better to use an official certificate for your apps domain and use /etc/hosts to create a loopback on your local computer too. This is because its tedious to have to switch certs between dev and prod.

提交回复
热议问题