with love
This commit is contained in:
		
							parent
							
								
									1b5ba16ad6
								
							
						
					
					
						commit
						5c8cf158db
					
				
							
								
								
									
										4
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							| @ -1,3 +1,7 @@ | |||||||
|  | all/ | ||||||
|  | server/ | ||||||
|  | client/ | ||||||
|  | 
 | ||||||
| # Logs | # Logs | ||||||
| logs | logs | ||||||
| *.log | *.log | ||||||
|  | |||||||
							
								
								
									
										32
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										32
									
								
								README.md
									
									
									
									
									
								
							| @ -1,15 +1,33 @@ | |||||||
| nodejs-self-signed-certificate-example | nodejs-self-signed-certificate-example | ||||||
| ====================================== | ====================================== | ||||||
| 
 | 
 | ||||||
| An example that works. |  | ||||||
| 
 |  | ||||||
| The end off all your self-signed certificate woes (in node.js at least) | The end off all your self-signed certificate woes (in node.js at least) | ||||||
| 
 | 
 | ||||||
|  | This is an easy-as-git-clone example that will get you on your way without | ||||||
|  | any `DEPTH_ZERO_SELF_SIGNED_CERT` or `SSL certificate problem: Invalid certificate chain` headaches. | ||||||
|  | 
 | ||||||
|  | See  | ||||||
|  | [the explanation](https://github.com/coolaj86/node-ssl-root-cas/wiki/Painless-Self-Signed-Certificates-in-node.js) for | ||||||
|  | the many details. | ||||||
|  | 
 | ||||||
| Test for yourself | Test for yourself | ||||||
| --- | --- | ||||||
| 
 | 
 | ||||||
| This is an easy-as-git-clone example that will get you on your way without | An example that works. | ||||||
| any `DEPTH_ZERO_SELF_SIGNED_CERT` or `SSL certificate problem: Invalid certificate chain` headaches. | 
 | ||||||
|  | ```bash | ||||||
|  | example | ||||||
|  | ├── package.json | ||||||
|  | ├── make-root-ca-and-certificates.sh | ||||||
|  | ├── serve.js | ||||||
|  | ├── request-without-warnings.js | ||||||
|  | ├── server | ||||||
|  | |   ├── my-private-root-ca.crt.pem | ||||||
|  | |   ├── my-server.crt.pem | ||||||
|  | |   └── my-server.key.pem | ||||||
|  | └── client | ||||||
|  |     └── my-private-root-ca.crt.pem | ||||||
|  | ``` | ||||||
| 
 | 
 | ||||||
| ### Get the repo | ### Get the repo | ||||||
| 
 | 
 | ||||||
| @ -25,7 +43,7 @@ npm install | |||||||
| bash test.sh | bash test.sh | ||||||
| ``` | ``` | ||||||
| 
 | 
 | ||||||
| ### Create certificates for `local.ldsconnect.org` | ### Create certificates for your FQDN | ||||||
| 
 | 
 | ||||||
| `local.ldsconnect.org` points to `localhost`, so it's ideal for your first test. | `local.ldsconnect.org` points to `localhost`, so it's ideal for your first test. | ||||||
| 
 | 
 | ||||||
| @ -36,7 +54,7 @@ bash make-root-ca-and-certificates.sh 'local.ldsconnect.org' | |||||||
| ### Run the server | ### Run the server | ||||||
| 
 | 
 | ||||||
| ```bash | ```bash | ||||||
| node ./serve.js 4443 & | node ./serve.js 8043 & | ||||||
| # use `fg` and `ctrl+c` to kill | # use `fg` and `ctrl+c` to kill | ||||||
| ``` | ``` | ||||||
| 
 | 
 | ||||||
| @ -50,7 +68,7 @@ Visit in a web browser | |||||||
| Test (warning free) in node.js | Test (warning free) in node.js | ||||||
| 
 | 
 | ||||||
| ```bash | ```bash | ||||||
| node ./request-without-warnings.js 4443 | node ./request-without-warnings.js 8043 | ||||||
| ``` | ``` | ||||||
| 
 | 
 | ||||||
| Test (warning free) with cURL | Test (warning free) with cURL | ||||||
|  | |||||||
| @ -5,11 +5,12 @@ var https = require('https') | |||||||
|   , fs = require('fs') |   , fs = require('fs') | ||||||
|   , path = require('path') |   , path = require('path') | ||||||
|   , ca = fs.readFileSync(path.join(__dirname, 'client', 'my-private-root-ca.crt.pem')) |   , ca = fs.readFileSync(path.join(__dirname, 'client', 'my-private-root-ca.crt.pem')) | ||||||
|   , port = process.argv[2] || 4443 |   , port = process.argv[2] || 8043 | ||||||
|  |   , hostname = process.argv[3] || 'local.ldsconnect.org' | ||||||
|   ; |   ; | ||||||
| 
 | 
 | ||||||
| var options = { | var options = { | ||||||
|   host: 'local.ldsconnect.org' |   host: hostname | ||||||
| , port: port | , port: port | ||||||
| , path: '/' | , path: '/' | ||||||
| , ca: ca | , ca: ca | ||||||
|  | |||||||
							
								
								
									
										2
									
								
								serve.js
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								serve.js
									
									
									
									
									
								
							| @ -2,7 +2,7 @@ | |||||||
| 'use strict'; | 'use strict'; | ||||||
| 
 | 
 | ||||||
| var https = require('https') | var https = require('https') | ||||||
|   , port = process.argv[2] || 4443 |   , port = process.argv[2] || 8043 | ||||||
|   , fs = require('fs') |   , fs = require('fs') | ||||||
|   , path = require('path') |   , path = require('path') | ||||||
|   , server |   , server | ||||||
|  | |||||||
							
								
								
									
										32
									
								
								test.sh
									
									
									
									
									
								
							
							
						
						
									
										32
									
								
								test.sh
									
									
									
									
									
								
							| @ -1,10 +1,30 @@ | |||||||
| #!/bin/bash | #!/bin/bash | ||||||
| 
 | 
 | ||||||
| bash make-root-ca-and-certificates.sh 'local.ldsconnect.org' | bash make-root-ca-and-certificates.sh 'local.ldsconnect.org' | ||||||
| 
 | echo "" | ||||||
| node ./serve.js & | 
 | ||||||
| 
 | echo "" | ||||||
| sleep 2 | node ./serve.js 8043 & | ||||||
| 
 | NODE_PID=$! | ||||||
| node ./request-without-warnings.js | sleep 1 | ||||||
|  | 
 | ||||||
|  | echo "" | ||||||
|  | echo "" | ||||||
|  | node ./request-without-warnings.js 8043 'local.ldsconnect.org' | ||||||
|  | echo -n " - without warnings, love node.js' https" | ||||||
|  | echo "" | ||||||
|  | sleep 1 | ||||||
|  | 
 | ||||||
|  | echo "" | ||||||
|  | curl https://local.ldsconnect.org:8043 \ | ||||||
|  |   --cacert client/my-private-root-ca.crt.pem | ||||||
|  | echo -n " - without warnings, love cURL" | ||||||
|  | echo "" | ||||||
|  | sleep 1 | ||||||
|  | 
 | ||||||
|  | # For lots of output about the ssl connection try -v | ||||||
|  | #curl -v https://local.ldsconnect.org:8043 \ | ||||||
|  | #  --cacert client/my-private-root-ca.crt.pem | ||||||
|  | 
 | ||||||
|  | kill ${NODE_PID} | ||||||
| echo "" | echo "" | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user