Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example Usage #2

Closed
konsumer opened this issue May 17, 2013 · 4 comments
Closed

Example Usage #2

konsumer opened this issue May 17, 2013 · 4 comments

Comments

@konsumer
Copy link

Thanks for making pem!

Took me a minute to work out how to use it for simple self-signed key HTTPS, thought I might give you examples for your docs. These are both valid for 1 day, and require root perms for the low port (https standard 443).

Basic https

var https = require("https"),
    pem = require('pem');

pem.createCertificate({days:1, selfSigned:true}, function(err, keys){
    https.createServer({key: keys.serviceKey, cert: keys.certificate}, function(req, res){
        res.end("o hai!")
    }).listen(443);
});

Express

var https = require("https"),
    pem = require('pem'),
    express = require('express');

pem.createCertificate({days:1, selfSigned:true}, function(err, keys){
    var app = express();

    app.get('/',  requireAuth, function(req, res){
        res.send("o hai!");
    });

    https.createServer({key: keys.serviceKey, cert: keys.certificate}, app).listen(443);
});
@andris9
Copy link
Collaborator

andris9 commented May 17, 2013

If you'd create a pull request, I'd happily add this to the docs (Y)

@konsumer
Copy link
Author

Sweet! Already have forked for adding native support (#3), do you have a preferred method for adding the changes back in? As I understand it, it will keep updating the fork when I push to it.

@andris9
Copy link
Collaborator

andris9 commented May 17, 2013

i can checkout only specific files (eg. readme.md) from your fork, so it doesn't matter if you change other files as well

@konsumer
Copy link
Author

Cool. submitted.

Dexus added a commit that referenced this issue Feb 27, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants