File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -102,7 +102,13 @@ if (process.platform !== 'win32') {
102102
103103// Finally starting ldnode
104104var ldnode = require ( '../index' ) ;
105- var app = ldnode . createServer ( argv ) ;
105+ var app ;
106+ try {
107+ app = ldnode . createServer ( argv ) ;
108+ } catch ( e ) {
109+ console . log ( e . message ) ;
110+ return 1 ;
111+ }
106112app . listen ( argv . port , function ( ) {
107113 debug ( 'LDP started on port ' + argv . port ) ;
108114} ) ;
Original file line number Diff line number Diff line change @@ -78,11 +78,39 @@ function createServer(argv) {
7878 if ( opts && ( opts . webid || opts . key || opts . cert ) ) {
7979 debug ( "SSL Private Key path: " + opts . key ) ;
8080 debug ( "SSL Certificate path: " + opts . cert ) ;
81+
82+ if ( ! opts . cert && ! opts . key ) {
83+ throw new Error ( "Missing SSL cert and SSL key to enable WebID" ) ;
84+ }
85+
86+ if ( ! opts . key && opts . cert ) {
87+ throw new Error ( "Missing path for SSL key" ) ;
88+ }
89+
90+ if ( ! opts . cert && opts . key ) {
91+ throw new Error ( "Missing path for SSL cert" ) ;
92+ }
93+
94+ var key ;
95+ try {
96+ key = fs . readFileSync ( opts . key ) ;
97+ } catch ( e ) {
98+ throw new Error ( "Can't find SSL key in " + opts . key ) ;
99+ }
100+
101+ var cert ;
102+ try {
103+ cert = fs . readFileSync ( opts . cert ) ;
104+ } catch ( e ) {
105+ throw new Error ( "Can't find SSL cert in " + opts . cert ) ;
106+ }
107+
81108 var credentials = {
82- key : fs . readFileSync ( opts . key ) ,
83- cert : fs . readFileSync ( opts . cert ) ,
84- requestCert : true
85- } ;
109+ key : key ,
110+ cert : cert ,
111+ requestCert : true
112+ } ;
113+
86114 debug ( "Private Key: " + credentials . key ) ;
87115 debug ( "Certificate: " + credentials . cert ) ;
88116
You can’t perform that action at this time.
0 commit comments