updates
This commit is contained in:
		
							parent
							
								
									14d3558943
								
							
						
					
					
						commit
						2f2d0783d7
					
				| @ -60,8 +60,12 @@ LeCore.getAcmeUrls( | ||||
|         // record to disk (or db) | ||||
| 
 | ||||
|         LeCore.getCertificate( | ||||
|           { domainPrivateKeyPem: domainPrivateKeyPem | ||||
|           { newAuthzUrl: urls.newAuthz | ||||
|           , newCertUrl: urls.newCert | ||||
| 
 | ||||
|           , domainPrivateKeyPem: domainPrivateKeyPem | ||||
|           , accountPrivateKeyPem: accountPrivateKeyPem | ||||
| 
 | ||||
|           , setChallenge: challengeStore.set | ||||
|           , removeChallenge: challengeStore.remove | ||||
|           } | ||||
|  | ||||
| @ -63,9 +63,8 @@ function runDemo() { | ||||
|         , accountPrivateKeyPem: accountPrivateKeyPem | ||||
|         , agreeToTerms: function (tosUrl, done) { | ||||
| 
 | ||||
|               // agree to these exact terms
 | ||||
|               console.log('[tosUrl]'); | ||||
|               console.log(tosUrl); | ||||
|               // agree to the exact version of these terms
 | ||||
|               console.log('[tosUrl]:', tosUrl); | ||||
|               done(null, tosUrl); | ||||
|           } | ||||
|         } | ||||
| @ -74,15 +73,19 @@ function runDemo() { | ||||
|             // Note: you should save the registration
 | ||||
|             // record to disk (or db)
 | ||||
|             console.log('[regr]'); | ||||
|             console.log(regr); | ||||
|             console.log(err || regr); | ||||
| 
 | ||||
|             console.log('Registering New Certificate'); | ||||
|             LeCore.getCertificate( | ||||
|                 { domainPrivateKeyPem: domainPrivateKeyPem | ||||
|                 { newAuthzUrl: acmeUrls.newAuthz | ||||
|                 , newCertUrl: acmeUrls.newCert | ||||
| 
 | ||||
|                 , domainPrivateKeyPem: domainPrivateKeyPem | ||||
|                 , accountPrivateKeyPem: accountPrivateKeyPem | ||||
|                 , domains: domains | ||||
| 
 | ||||
|                 , setChallenge: challengeStore.set | ||||
|                 , removeChallenge: challengeStore.remove | ||||
|                 , domains: domains | ||||
|                 } | ||||
|               , function (err, certs) { | ||||
| 
 | ||||
| @ -90,7 +93,7 @@ function runDemo() { | ||||
|                   certStore.set(domains[0], certs, function () { | ||||
| 
 | ||||
|                     console.log('[certs]'); | ||||
|                     console.log(certs); | ||||
|                     console.log(err || certs); | ||||
| 
 | ||||
|                   }); | ||||
|                    | ||||
|  | ||||
| @ -19,10 +19,18 @@ module.exports.create = function (deps) { | ||||
|     var state={ | ||||
|       validatedDomains:[] | ||||
|     , validAuthorizationUrls:[] | ||||
|     , newAuthorizationUrl: options.newAuthorizationUrl || options.newAuthz | ||||
|     , newCertificateUrl: options.newCertificateUrl || options.newCert | ||||
|     , newAuthzUrl: options.newAuthzUrl | ||||
|     , newCertUrl: options.newCertUrl | ||||
|     }; | ||||
| 
 | ||||
|     console.log('state'); | ||||
|     console.log(state); | ||||
|     if (!options.newAuthzUrl) { | ||||
|       return handleErr(new Error("options.newAuthzUrl must be the authorization url")); | ||||
|     } | ||||
|     if (!options.newCertUrl) { | ||||
|       return handleErr(new Error("options.newCertUrl must be the new certificate url")); | ||||
|     } | ||||
|     if (!options.accountPrivateKeyPem) { | ||||
|       return handleErr(new Error("options.accountPrivateKeyPem must be an ascii private key pem")); | ||||
|     } | ||||
| @ -64,7 +72,7 @@ module.exports.create = function (deps) { | ||||
|     function getChallenges(domain) { | ||||
|       state.domain=domain; | ||||
| 
 | ||||
|       state.acme.post(state.newAuthorizationUrl, { | ||||
|       state.acme.post(state.newAuthzUrl, { | ||||
|         resource:'new-authz', | ||||
|         identifier:{ | ||||
|           type:'dns', | ||||
| @ -90,7 +98,7 @@ module.exports.create = function (deps) { | ||||
|       } | ||||
| 
 | ||||
|       state.authorizationUrl=res.headers.location; | ||||
|       state.newCertificateUrl=links.next; | ||||
|       state.newCertUrl=links.next; | ||||
| 
 | ||||
|       authz=JSON.parse(body); | ||||
| 
 | ||||
| @ -156,7 +164,7 @@ module.exports.create = function (deps) { | ||||
|     function getCertificate() { | ||||
|       var csr=generateCsr(state.certPrivateKey, state.validatedDomains); | ||||
|       log('Requesting certificate...'); | ||||
|       state.acme.post(state.newCertificateUrl, { | ||||
|       state.acme.post(state.newCertUrl, { | ||||
|         resource:'new-cert', | ||||
|         csr:csr, | ||||
|         authorizations:state.validAuthorizationUrls | ||||
|  | ||||
| @ -22,8 +22,8 @@ module.exports.create = function (deps) { | ||||
|       cb(new Error("options.agreeToTerms must be function (tosUrl, fn => (err, true))")); | ||||
|       return; | ||||
|     } | ||||
|     if (!options.newReg) { | ||||
|       cb(new Error("options.newReg must be the a new registration url")); | ||||
|     if (!options.newRegUrl) { | ||||
|       cb(new Error("options.newRegUrl must be the a new registration url")); | ||||
|       return; | ||||
|     } | ||||
|     if (!options.email) { | ||||
| @ -38,7 +38,7 @@ module.exports.create = function (deps) { | ||||
|     register(); | ||||
| 
 | ||||
|     function register() { | ||||
|       state.acme.post(options.newReg, { | ||||
|       state.acme.post(options.newRegUrl, { | ||||
|         resource:'new-reg', | ||||
|         contact:['mailto:'+options.email] | ||||
|       }, getTerms); | ||||
| @ -77,7 +77,7 @@ module.exports.create = function (deps) { | ||||
|           request.get(state.termsUrl, getAgreement); | ||||
|         }); | ||||
|       } else { | ||||
|         cb(); | ||||
|         cb(null, null); | ||||
|       } | ||||
|     } | ||||
| 
 | ||||
| @ -100,11 +100,30 @@ module.exports.create = function (deps) { | ||||
|         resource:'reg', | ||||
|         agreement:state.termsUrl | ||||
|       }, function(err, res, body) { | ||||
|         var data; | ||||
| 
 | ||||
|         if (err || Math.floor(res.statusCode/100)!==2) { | ||||
|           return handleErr(err, 'Couldn\'t POST agreement back to server', body); | ||||
|         } else { | ||||
|           cb(null, body); | ||||
|         } | ||||
| 
 | ||||
|         data = body; | ||||
|         // handle for node and browser
 | ||||
|         if ('string' === typeof body) { | ||||
|           try { | ||||
|             data = JSON.parse(body); | ||||
|           } catch(e) { | ||||
|             // ignore
 | ||||
|           } | ||||
|         } else { | ||||
|           // might be a buffer
 | ||||
|           data = body.toString('utf8'); | ||||
|           if (!(data.length > 10)) { | ||||
|             // probably json
 | ||||
|             data = body; | ||||
|           } | ||||
|         } | ||||
| 
 | ||||
|         cb(null, data); | ||||
|       }); | ||||
|     } | ||||
| 
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user