mirror of
				https://github.com/therootcompany/acme.js.git
				synced 2024-11-16 17:29:00 +00:00 
			
		
		
		
	Compare commits
	
		
			No commits in common. "45fd6962f259c6399de05589848d68be42894316" and "bef931f28f08e0d5337dfefca33d7f98eb6651ff" have entirely different histories.
		
	
	
		
			45fd6962f2
			...
			bef931f28f
		
	
		
							
								
								
									
										144
									
								
								acme.js
									
									
									
									
									
								
							
							
						
						
									
										144
									
								
								acme.js
									
									
									
									
									
								
							| @ -756,8 +756,12 @@ ACME._postChallenge = function (me, options, kid, auth) { | |||||||
| 			altname: altname | 			altname: altname | ||||||
| 		}); | 		}); | ||||||
| 
 | 
 | ||||||
| 		// State can be pending while waiting ACME server to transition to
 | 		if ('processing' === resp.body.status) { | ||||||
| 		// processing
 | 			//#console.debug('poll: again', auth.url);
 | ||||||
|  | 			return ACME._wait(RETRY_INTERVAL).then(pollStatus); | ||||||
|  | 		} | ||||||
|  | 
 | ||||||
|  | 		// This state should never occur
 | ||||||
| 		if ('pending' === resp.body.status) { | 		if ('pending' === resp.body.status) { | ||||||
| 			if (count >= MAX_PEND) { | 			if (count >= MAX_PEND) { | ||||||
| 				return ACME._wait(RETRY_INTERVAL) | 				return ACME._wait(RETRY_INTERVAL) | ||||||
| @ -765,12 +769,7 @@ ACME._postChallenge = function (me, options, kid, auth) { | |||||||
| 					.then(respondToChallenge); | 					.then(respondToChallenge); | ||||||
| 			} | 			} | ||||||
| 			//#console.debug('poll: again', auth.url);
 | 			//#console.debug('poll: again', auth.url);
 | ||||||
| 			return ACME._wait(RETRY_INTERVAL).then(pollStatus); | 			return ACME._wait(RETRY_INTERVAL).then(respondToChallenge); | ||||||
| 		} |  | ||||||
| 
 |  | ||||||
| 		if ('processing' === resp.body.status) { |  | ||||||
| 			//#console.debug('poll: again', auth.url);
 |  | ||||||
| 			return ACME._wait(RETRY_INTERVAL).then(pollStatus); |  | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		// REMOVE DNS records as soon as the state is non-processing
 | 		// REMOVE DNS records as soon as the state is non-processing
 | ||||||
| @ -1013,84 +1012,73 @@ ACME._pollOrderStatus = function (me, options, kid, order, verifieds) { | |||||||
| 	var body = { csr: csr64 }; | 	var body = { csr: csr64 }; | ||||||
| 	var payload = JSON.stringify(body); | 	var payload = JSON.stringify(body); | ||||||
| 
 | 
 | ||||||
| 	function processResponse(resp) { | 	function pollCert() { | ||||||
| 		ACME._notify(me, options, 'certificate_status', { |  | ||||||
| 			subject: options.domains[0], |  | ||||||
| 			status: resp.body.status |  | ||||||
| 		}); |  | ||||||
| 
 |  | ||||||
| 		// https://tools.ietf.org/html/draft-ietf-acme-acme-12#section-7.1.3
 |  | ||||||
| 		// Possible values are: "pending" => ("invalid" || "ready") => "processing" => "valid"
 |  | ||||||
| 		if ('valid' === resp.body.status) { |  | ||||||
| 			var voucher = resp.body; |  | ||||||
| 			voucher._certificateUrl = resp.body.certificate; |  | ||||||
| 
 |  | ||||||
| 			return voucher; |  | ||||||
| 		} |  | ||||||
| 
 |  | ||||||
| 		if ('processing' === resp.body.status) { |  | ||||||
| 			return ACME._wait().then(pollStatus); |  | ||||||
| 		} |  | ||||||
| 
 |  | ||||||
| 		if (me.debug) { |  | ||||||
| 			console.debug( |  | ||||||
| 				'Error: bad status:\n' + JSON.stringify(resp.body, null, 2) |  | ||||||
| 			); |  | ||||||
| 		} |  | ||||||
| 
 |  | ||||||
| 		if ('pending' === resp.body.status) { |  | ||||||
| 			return Promise.reject( |  | ||||||
| 				new Error( |  | ||||||
| 					"Did not finalize order: status 'pending'." + |  | ||||||
| 						' Best guess: You have not accepted at least one challenge for each domain:\n' + |  | ||||||
| 						"Requested: '" + |  | ||||||
| 						options.domains.join(', ') + |  | ||||||
| 						"'\n" + |  | ||||||
| 						"Validated: '" + |  | ||||||
| 						verifieds.join(', ') + |  | ||||||
| 						"'\n" + |  | ||||||
| 						JSON.stringify(resp.body, null, 2) |  | ||||||
| 				) |  | ||||||
| 			); |  | ||||||
| 		} |  | ||||||
| 
 |  | ||||||
| 		if ('invalid' === resp.body.status) { |  | ||||||
| 			return Promise.reject( |  | ||||||
| 				E.ORDER_INVALID(options, verifieds, resp) |  | ||||||
| 			); |  | ||||||
| 		} |  | ||||||
| 
 |  | ||||||
| 		if ('ready' === resp.body.status) { |  | ||||||
| 			return Promise.reject( |  | ||||||
| 				E.DOUBLE_READY_ORDER(options, verifieds, resp) |  | ||||||
| 			); |  | ||||||
| 		} |  | ||||||
| 
 |  | ||||||
| 		return Promise.reject( |  | ||||||
| 			E.UNHANDLED_ORDER_STATUS(options, verifieds, resp) |  | ||||||
| 		); |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	function pollStatus() { |  | ||||||
| 		return U._jwsRequest(me, { |  | ||||||
| 			accountKey: options.accountKey, |  | ||||||
| 			url: order._orderUrl, |  | ||||||
| 			protected: { kid: kid }, |  | ||||||
| 			payload: Enc.binToBuf('') |  | ||||||
| 		}).then(processResponse); |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	function finalizeOrder() { |  | ||||||
| 		//#console.debug('[ACME.js] pollCert:', order._finalizeUrl);
 | 		//#console.debug('[ACME.js] pollCert:', order._finalizeUrl);
 | ||||||
| 		return U._jwsRequest(me, { | 		return U._jwsRequest(me, { | ||||||
| 			accountKey: options.accountKey, | 			accountKey: options.accountKey, | ||||||
| 			url: order._finalizeUrl, | 			url: order._finalizeUrl, | ||||||
| 			protected: { kid: kid }, | 			protected: { kid: kid }, | ||||||
| 			payload: Enc.strToBuf(payload) | 			payload: Enc.strToBuf(payload) | ||||||
| 		}).then(processResponse); | 		}).then(function (resp) { | ||||||
|  | 			ACME._notify(me, options, 'certificate_status', { | ||||||
|  | 				subject: options.domains[0], | ||||||
|  | 				status: resp.body.status | ||||||
|  | 			}); | ||||||
|  | 
 | ||||||
|  | 			// https://tools.ietf.org/html/draft-ietf-acme-acme-12#section-7.1.3
 | ||||||
|  | 			// Possible values are: "pending" => ("invalid" || "ready") => "processing" => "valid"
 | ||||||
|  | 			if ('valid' === resp.body.status) { | ||||||
|  | 				var voucher = resp.body; | ||||||
|  | 				voucher._certificateUrl = resp.body.certificate; | ||||||
|  | 
 | ||||||
|  | 				return voucher; | ||||||
|  | 			} | ||||||
|  | 
 | ||||||
|  | 			if ('processing' === resp.body.status) { | ||||||
|  | 				return ACME._wait().then(pollCert); | ||||||
|  | 			} | ||||||
|  | 
 | ||||||
|  | 			if (me.debug) { | ||||||
|  | 				console.debug( | ||||||
|  | 					'Error: bad status:\n' + JSON.stringify(resp.body, null, 2) | ||||||
|  | 				); | ||||||
|  | 			} | ||||||
|  | 
 | ||||||
|  | 			if ('pending' === resp.body.status) { | ||||||
|  | 				return Promise.reject( | ||||||
|  | 					new Error( | ||||||
|  | 						"Did not finalize order: status 'pending'." + | ||||||
|  | 							' Best guess: You have not accepted at least one challenge for each domain:\n' + | ||||||
|  | 							"Requested: '" + | ||||||
|  | 							options.domains.join(', ') + | ||||||
|  | 							"'\n" + | ||||||
|  | 							"Validated: '" + | ||||||
|  | 							verifieds.join(', ') + | ||||||
|  | 							"'\n" + | ||||||
|  | 							JSON.stringify(resp.body, null, 2) | ||||||
|  | 					) | ||||||
|  | 				); | ||||||
|  | 			} | ||||||
|  | 
 | ||||||
|  | 			if ('invalid' === resp.body.status) { | ||||||
|  | 				return Promise.reject( | ||||||
|  | 					E.ORDER_INVALID(options, verifieds, resp) | ||||||
|  | 				); | ||||||
|  | 			} | ||||||
|  | 
 | ||||||
|  | 			if ('ready' === resp.body.status) { | ||||||
|  | 				return Promise.reject( | ||||||
|  | 					E.DOUBLE_READY_ORDER(options, verifieds, resp) | ||||||
|  | 				); | ||||||
|  | 			} | ||||||
|  | 
 | ||||||
|  | 			return Promise.reject( | ||||||
|  | 				E.UNHANDLED_ORDER_STATUS(options, verifieds, resp) | ||||||
|  | 			); | ||||||
|  | 		}); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	return finalizeOrder(); | 	return pollCert(); | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| ACME._redeemCert = function (me, options, kid, voucher) { | ACME._redeemCert = function (me, options, kid, voucher) { | ||||||
|  | |||||||
							
								
								
									
										2
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										2
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							| @ -1,6 +1,6 @@ | |||||||
| { | { | ||||||
| 	"name": "@root/acme", | 	"name": "@root/acme", | ||||||
| 	"version": "3.1.1", | 	"version": "3.1.0", | ||||||
| 	"lockfileVersion": 1, | 	"lockfileVersion": 1, | ||||||
| 	"requires": true, | 	"requires": true, | ||||||
| 	"dependencies": { | 	"dependencies": { | ||||||
|  | |||||||
| @ -1,6 +1,6 @@ | |||||||
| { | { | ||||||
| 	"name": "@root/acme", | 	"name": "@root/acme", | ||||||
| 	"version": "3.1.1", | 	"version": "3.1.0", | ||||||
| 	"description": "Free SSL certificates for Node.js and Browsers. Issued via Let's Encrypt", | 	"description": "Free SSL certificates for Node.js and Browsers. Issued via Let's Encrypt", | ||||||
| 	"homepage": "https://rootprojects.org/acme/", | 	"homepage": "https://rootprojects.org/acme/", | ||||||
| 	"main": "acme.js", | 	"main": "acme.js", | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user