Lab-https-ssl-notes

From GersteinInfo

(Difference between revisions)
Jump to: navigation, search
Line 8: Line 8:
* With nodejs
* With nodejs
-
```javascript
+
```javascript
-
 
+
var https = require('https');
-
var https = require('https');
+
//create a folder can only access by yourself, change the key name to 'key.pem', certificate name to 'cert.pem'
-
//create a folder can only access by yourself, change the key name to 'key.pem', certificate name to 'cert.pem'
+
//
-
//
+
var ssldir=xxxxx;
-
var ssldir=xxxxx;
+
var options = {  
-
var options = {  
+
key: fs.readFileSync(ssldir+'.localhost-ssl/key.pem'),
-
key: fs.readFileSync(ssldir+'.localhost-ssl/key.pem'),  
+
cert: fs.readFileSync(ssldir+'.localhost-ssl/cert.pem')  
-
cert: fs.readFileSync(ssldir+'.localhost-ssl/cert.pem')  
+
};
-
};
+
//need run as root to use 443 as the listenning port
-
 
+
//or give a different number like: 8443
-
//need run as root to use 443 as the listenning port
+
https.createServer(options, app).listen(443);
-
//or give a different number like: 8443
+
....
-
https.createServer(options, app).listen(443);
+
```
-
....
+
-
 
+
-
```
+

Revision as of 15:52, 27 February 2019

Mihali has created lab-wide SSL encryption files ready for use with *.gersteinlab.org websites.

Here are some notes on how to use it.

  • With Apache
  (under development)
  • With nodejs
```javascript
var https = require('https');
//create a folder can only access by yourself, change the key name to 'key.pem', certificate name to 'cert.pem'
//
var ssldir=xxxxx;
var options = { 
key: fs.readFileSync(ssldir+'.localhost-ssl/key.pem'),  
cert: fs.readFileSync(ssldir+'.localhost-ssl/cert.pem') 
};
//need run as root to use 443 as the listenning port
//or give a different number like: 8443
https.createServer(options, app).listen(443);
....
```
Personal tools