ugly first steps
This commit is contained in:
		
							parent
							
								
									4fd5fd8bd9
								
							
						
					
					
						commit
						40200e4dc5
					
				
							
								
								
									
										134
									
								
								index.html
									
									
									
									
									
								
							
							
						
						
									
										134
									
								
								index.html
									
									
									
									
									
								
							| @ -3,13 +3,143 @@ | |||||||
|     <title>Greenlock™</title> |     <title>Greenlock™</title> | ||||||
|   </head> |   </head> | ||||||
|   <body> |   <body> | ||||||
|     <form> | 
 | ||||||
|  |     <!-- Step 1 Choose Domain(s) --> | ||||||
|  |     <form class="js-acme-form js-acme-form-domains"> | ||||||
|       <label>What's your domain?</label> |       <label>What's your domain?</label> | ||||||
|       <input type="text" placeholder="www.example.com"> |       <input class="js-acme-domains" type="text" placeholder="example.com,*.example.com" required> | ||||||
|       <button type="submit">Next</button> |       <button type="submit">Next</button> | ||||||
|     </form> |     </form> | ||||||
| 
 | 
 | ||||||
|  |     <!-- Step 2 Create Account --> | ||||||
|  |     <form class="js-acme-form js-acme-form-account"> | ||||||
|  |       <label>What's your email?</label> | ||||||
|  |       <input class="js-acme-account-email" type="email" placeholder="john@doe.family" required> | ||||||
|  |       <label><input class="js-acme-account-tos" type="checkbox" required> | ||||||
|  |         Agree to <a class="js-le-tos">Let's Encrypt Terms of Service</a>?</label> | ||||||
|  |       <label><input class="js-greenlock-account-tos" type="checkbox" required> | ||||||
|  |         Agree to <a class="js-gl-tos">Greenlock Terms of Service</a>?</label> | ||||||
|  |       <a href="#">advanced (use existing account)</a> | ||||||
|  |       <button type="submit">Next</button> | ||||||
|  |     </form> | ||||||
|  | 
 | ||||||
|  |     <!-- Step 3 Set Challanges --> | ||||||
|  |     <form class="js-acme-form js-acme-form-challenges"> | ||||||
|  |       <label>How will you validate your domain?</label> | ||||||
|  |       <label><input class="js-acme-challenge-type" type="radio" value="http-01" checked required> | ||||||
|  |         File Upload to HTTP Web Server</label> | ||||||
|  |       <label><input class="js-acme-challenge-type" type="radio" value="dns-01" required> | ||||||
|  |         TXT Records on DNS Name Server</label> | ||||||
|  | 
 | ||||||
|  |       Verify Domains & Sub-Domains: | ||||||
|  | 
 | ||||||
|  |       <table class="js-acme-table-http-01"> | ||||||
|  |         <thead> | ||||||
|  |           <tr> | ||||||
|  |             <th>Hostname</th> | ||||||
|  |             <th>File Location</th> | ||||||
|  |             <th>File Contents</th> | ||||||
|  |           </tr> | ||||||
|  |         </thead> | ||||||
|  |         <tbody> | ||||||
|  |           <tr> | ||||||
|  |             <td>example.com</td> | ||||||
|  |             <td>.well-known/acme-challenge/xxx</td> | ||||||
|  |             <td>sec.ret</td> | ||||||
|  |           </tr> | ||||||
|  |         </tbody> | ||||||
|  |       </table> | ||||||
|  | 
 | ||||||
|  |       <table class="js-acme-table-dns-01"> | ||||||
|  |         <thead> | ||||||
|  |           <tr> | ||||||
|  |             <th>Hostname</th> | ||||||
|  |             <th>TXT Host</th> | ||||||
|  |             <th>TXT Value</th> | ||||||
|  |           </tr> | ||||||
|  |         </thead> | ||||||
|  |         <tbody> | ||||||
|  |           <tr> | ||||||
|  |             <td>example.com</td> | ||||||
|  |             <td>_acme-challenge.example.com</td> | ||||||
|  |             <td>4A54</td> | ||||||
|  |           </tr> | ||||||
|  |         </tbody> | ||||||
|  |       </table> | ||||||
|  | 
 | ||||||
|  |       <div class="js-acme-wildcards"> | ||||||
|  |         Verify Wildcard Domains: | ||||||
|  | 
 | ||||||
|  |         <table class="js-acme-table-wildcards"> | ||||||
|  |           <thead> | ||||||
|  |             <tr> | ||||||
|  |               <th>Hostname</th> | ||||||
|  |               <th>TXT Host</th> | ||||||
|  |               <th>TXT Value</th> | ||||||
|  |             </tr> | ||||||
|  |           </thead> | ||||||
|  |           <tbody> | ||||||
|  |             <tr> | ||||||
|  |               <td>example.com</td> | ||||||
|  |               <td>_acme-challenge.example.com</td> | ||||||
|  |               <td>4A54</td> | ||||||
|  |             </tr> | ||||||
|  |           </tbody> | ||||||
|  |         </table> | ||||||
|  |       </div> | ||||||
|  | 
 | ||||||
|  |       <button type="submit">Next</button> | ||||||
|  |     </form> | ||||||
|  | 
 | ||||||
|  |     <!-- Step 4 Process Challanges --> | ||||||
|  |     <form class="js-acme-form js-acme-form-poll"> | ||||||
|  |       Verifying Domains... | ||||||
|  | 
 | ||||||
|  |       <table class="js-acme-table-verifying"> | ||||||
|  |         <thead> | ||||||
|  |           <tr> | ||||||
|  |             <th>Hostname</th> | ||||||
|  |             <th>Type</th> | ||||||
|  |             <th>Pass</th> | ||||||
|  |           </tr> | ||||||
|  |         </thead> | ||||||
|  |         <tbody> | ||||||
|  |           <tr> | ||||||
|  |             <td>example.com</td> | ||||||
|  |             <td>http-01</td> | ||||||
|  |             <td>-</td> | ||||||
|  |           </tr> | ||||||
|  |         </tbody> | ||||||
|  |       </table> | ||||||
|  | 
 | ||||||
|  |       <a href="#">advanced (use existing keypair for domain)</a> | ||||||
|  | 
 | ||||||
|  |       <button type="submit">Next</button> | ||||||
|  |     </form> | ||||||
|  | 
 | ||||||
|  |     <!-- Step 4 Process Challanges --> | ||||||
|  |     <form class="js-acme-form js-acme-form-download"> | ||||||
|  |       <label>privkey.pem</label> | ||||||
|  |       <textarea>-</textarea> | ||||||
|  | 
 | ||||||
|  |       <label>fullchain.pem</label> | ||||||
|  |       <textarea>-</textarea> | ||||||
|  | 
 | ||||||
|  |       <label>cert.pem</label> | ||||||
|  |       <textarea>-</textarea> | ||||||
|  | 
 | ||||||
|  |       <label>chain.pem</label> | ||||||
|  |       <textarea>-</textarea> | ||||||
|  | 
 | ||||||
|  |       <button type="button">Download SSL Certificates</button> | ||||||
|  | 
 | ||||||
|  |       <a href="#">Advanced (copy and paste)</a> | ||||||
|  | 
 | ||||||
|  |       <button type="submit">Start Over</button> | ||||||
|  |     </form> | ||||||
|  | 
 | ||||||
|     <input class="js-acme-directory-url" type="url" placeholder="ACME directory url"> |     <input class="js-acme-directory-url" type="url" placeholder="ACME directory url"> | ||||||
|  | 
 | ||||||
|     <script src="./js/pkijs.org/v1.3.33/common.js"></script> |     <script src="./js/pkijs.org/v1.3.33/common.js"></script> | ||||||
|     <script src="./js/pkijs.org/v1.3.33/asn1.js"></script> |     <script src="./js/pkijs.org/v1.3.33/asn1.js"></script> | ||||||
|     <script src="./js/pkijs.org/v1.3.33/x509_schema.js"></script> |     <script src="./js/pkijs.org/v1.3.33/x509_schema.js"></script> | ||||||
|  | |||||||
							
								
								
									
										55
									
								
								js/app.js
									
									
									
									
									
								
							
							
						
						
									
										55
									
								
								js/app.js
									
									
									
									
									
								
							| @ -1,6 +1,57 @@ | |||||||
| (function () { | (function () { | ||||||
| 'use strict'; | 'use strict'; | ||||||
| 
 | 
 | ||||||
|   //window.document.querySelector('.js-acme-directory-url').value = 'https://acme-v02.api.letsencrypt.org/directory';
 |   var $qs = function (s) { return window.document.querySelector(s); }; | ||||||
|   window.document.querySelector('.js-acme-directory-url').value = 'https://acme-staging-v02.api.letsencrypt.org/directory'; |   var $qsa = function (s) { return window.document.querySelectorAll(s); }; | ||||||
|  |   var info = {}; | ||||||
|  |   var steps = {}; | ||||||
|  |   var i = 1; | ||||||
|  | 
 | ||||||
|  |   //$qs('.js-acme-directory-url').value = 'https://acme-v02.api.letsencrypt.org/directory';
 | ||||||
|  |   $qs('.js-acme-directory-url').value = 'https://acme-staging-v02.api.letsencrypt.org/directory'; | ||||||
|  | 
 | ||||||
|  |   function hideForms() { | ||||||
|  |     $qsa('.js-acme-form').forEach(function (el) { | ||||||
|  |       el.hidden = true; | ||||||
|  |     }); | ||||||
|  |   } | ||||||
|  | 
 | ||||||
|  |   $qs('.js-acme-form-domains').addEventListener('submit', function (ev) { | ||||||
|  |     ev.preventDefault(); | ||||||
|  |     info.identifiers = $qs('.js-acme-domains').value.split(/,/g).map(function (hostname) { | ||||||
|  |       return { type: 'dns', value: hostname.trim() }; | ||||||
|  |     }); | ||||||
|  | 
 | ||||||
|  |     return BACME.directory($qs('.js-acme-directory-url').value).then(function () { | ||||||
|  |       i += 1; | ||||||
|  |       steps[i](); | ||||||
|  |     }); | ||||||
|  |   }); | ||||||
|  | 
 | ||||||
|  |   steps[1] = function () { | ||||||
|  |     hideForms(); | ||||||
|  |     $qs('.js-acme-form-domains').hidden = false; | ||||||
|  |   }; | ||||||
|  | 
 | ||||||
|  |   steps[2] = function () { | ||||||
|  |     hideForms(); | ||||||
|  |     $qs('.js-acme-form-account').hidden = false; | ||||||
|  |   }; | ||||||
|  | 
 | ||||||
|  |   steps[3] = function () { | ||||||
|  |     hideForms(); | ||||||
|  |     $qs('.js-acme-form-challenges').hidden = false; | ||||||
|  |   }; | ||||||
|  | 
 | ||||||
|  |   steps[4] = function () { | ||||||
|  |     hideForms(); | ||||||
|  |     $qs('.js-acme-form-poll').hidden = false; | ||||||
|  |   } | ||||||
|  | 
 | ||||||
|  |   steps[5] = function () { | ||||||
|  |     hideForms(); | ||||||
|  |     $qs('.js-acme-form-download').hidden = false; | ||||||
|  |   } | ||||||
|  | 
 | ||||||
|  |   steps[1](); | ||||||
| }()); | }()); | ||||||
|  | |||||||
							
								
								
									
										18
									
								
								js/bacme.js
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								js/bacme.js
									
									
									
									
									
								
							| @ -8,13 +8,13 @@ var webCrypto = exports.crypto; | |||||||
| var directoryUrl = 'https://acme-staging-v02.api.letsencrypt.org/directory'; | var directoryUrl = 'https://acme-staging-v02.api.letsencrypt.org/directory'; | ||||||
| var directory; | var directory; | ||||||
| 
 | 
 | ||||||
| var nonceUrl = directory.newNonce || 'https://acme-staging-v02.api.letsencrypt.org/acme/new-nonce'; | var nonceUrl; | ||||||
| var nonce; | var nonce; | ||||||
| 
 | 
 | ||||||
| var accountKeypair; | var accountKeypair; | ||||||
| var accountJwk; | var accountJwk; | ||||||
| 
 | 
 | ||||||
| var accountUrl = directory.newAccount; | var accountUrl; | ||||||
| var signedAccount; | var signedAccount; | ||||||
| 
 | 
 | ||||||
| BACME.challengePrefixes = { | BACME.challengePrefixes = { | ||||||
| @ -38,6 +38,9 @@ BACME.directory = function (url) { | |||||||
| 		BACME._logHeaders(resp); | 		BACME._logHeaders(resp); | ||||||
| 		return resp.json().then(function (body) { | 		return resp.json().then(function (body) { | ||||||
| 			directory = body; | 			directory = body; | ||||||
|  |       nonceUrl = directory.newNonce || 'https://acme-staging-v02.api.letsencrypt.org/acme/new-nonce'; | ||||||
|  |       accountUrl = directory.newAccount || 'https://acme-staging-v02.api.letsencrypt.org/acme/new-account'; | ||||||
|  |       orderUrl = directory.newOrder || "https://acme-staging-v02.api.letsencrypt.org/acme/new-order"; | ||||||
|       BACME._logBody(body); |       BACME._logBody(body); | ||||||
|       return body; |       return body; | ||||||
| 		}); | 		}); | ||||||
| @ -169,7 +172,7 @@ BACME.accounts.set = function () { | |||||||
| 	}); | 	}); | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| var orderUrl = directory.newOrder || "https://acme-staging-v02.api.letsencrypt.org/acme/new-order"; | var orderUrl; | ||||||
| var signedOrder; | var signedOrder; | ||||||
| 
 | 
 | ||||||
| BACME.orders = {}; | BACME.orders = {}; | ||||||
| @ -305,7 +308,8 @@ BACME.challenges['http-01'] = function () { | |||||||
|     path: httpPath |     path: httpPath | ||||||
|   , value: keyAuth |   , value: keyAuth | ||||||
|   }; |   }; | ||||||
| }); | }; | ||||||
|  | 
 | ||||||
| BACME.challenges['dns-01'] = function () { | BACME.challenges['dns-01'] = function () { | ||||||
| 	return window.crypto.subtle.digest( | 	return window.crypto.subtle.digest( | ||||||
| 		{ name: "SHA-256", } | 		{ name: "SHA-256", } | ||||||
| @ -326,7 +330,7 @@ BACME.challenges['dns-01'] = function () { | |||||||
|     return { |     return { | ||||||
|       type: 'TXT' |       type: 'TXT' | ||||||
|     , host: dnsRecord |     , host: dnsRecord | ||||||
|     , answer: dnsAuth; |     , answer: dnsAuth | ||||||
|     }; |     }; | ||||||
| 	}); | 	}); | ||||||
| }; | }; | ||||||
| @ -424,13 +428,13 @@ BACME.domains.generateKeypair = function () { | |||||||
| 	}); | 	}); | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| BACME.order.generateCsr = function (keypair, domains) { | BACME.orders.generateCsr = function (keypair, domains) { | ||||||
|   return Promise.resolve(CSR.generate(keypair, domains)); |   return Promise.resolve(CSR.generate(keypair, domains)); | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| var certificateUrl; | var certificateUrl; | ||||||
| 
 | 
 | ||||||
| BACME.order.finalize = function () { | BACME.orders.finalize = function () { | ||||||
| 	var payload64 = jsto64( | 	var payload64 = jsto64( | ||||||
| 		{ csr: csr } | 		{ csr: csr } | ||||||
| 	); | 	); | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user