test key support BEFORE creating keys
This commit is contained in:
		
							parent
							
								
									df964d76c6
								
							
						
					
					
						commit
						8a0ccfa55f
					
				| @ -48,32 +48,37 @@ | |||||||
|       }); |       }); | ||||||
|     }); |     }); | ||||||
|   } |   } | ||||||
|   testEcdsaSupport().then(function () { |   function testKeypairSupport() { | ||||||
|     console.info("[crypto] ECDSA is supported"); |     return testEcdsaSupport().then(function () { | ||||||
|     BROWSER_SUPPORTS_ECDSA = true; |       console.info("[crypto] ECDSA is supported"); | ||||||
|     localStorage.setItem('version', '1'); |       BROWSER_SUPPORTS_ECDSA = true; | ||||||
|     return true; |       localStorage.setItem('version', '1'); | ||||||
|   }).catch(function () { |       return true; | ||||||
|     console.warn("[crypto] ECDSA is NOT fully supported"); |     }).catch(function () { | ||||||
|     BROWSER_SUPPORTS_ECDSA = false; |       console.warn("[crypto] ECDSA is NOT fully supported"); | ||||||
|  |       BROWSER_SUPPORTS_ECDSA = false; | ||||||
| 
 | 
 | ||||||
|     // fix previous firefox browsers
 |       // fix previous firefox browsers
 | ||||||
|     if (!localStorage.getItem('version')) { |       if (!localStorage.getItem('version')) { | ||||||
|       localStorage.clear(); |         localStorage.clear(); | ||||||
|       localStorage.getItem('version', '1'); |         localStorage.setItem('version', '1'); | ||||||
|  |       } | ||||||
|  | 
 | ||||||
|  |       return false; | ||||||
|  |     }); | ||||||
|  |   } | ||||||
|  |   testKeypairSupport().then(function (ecdsaSupport) { | ||||||
|  |     if (ecdsaSupport) { | ||||||
|  |       return true; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     // DO NOT RETURN HERE
 |     return testRsaSupport().then(function () { | ||||||
|     testRsaSupport().then(function () { |  | ||||||
|       console.info('[crypto] RSA is supported'); |       console.info('[crypto] RSA is supported'); | ||||||
|     }).catch(function (err) { |     }).catch(function (err) { | ||||||
|       console.error('[crypto] could not use either EC nor RSA.'); |       console.error('[crypto] could not use either EC nor RSA.'); | ||||||
|       console.error(err); |       console.error(err); | ||||||
|       window.alert("Your browser is cryptography support (neither RSA or EC is usable). Please use Chrome, Firefox, or Safari."); |       window.alert("Your browser is cryptography support (neither RSA or EC is usable). Please use Chrome, Firefox, or Safari."); | ||||||
|     }); |     }); | ||||||
| 
 |  | ||||||
|     // RETURN HERE
 |  | ||||||
|     return false; |  | ||||||
|   }); |   }); | ||||||
| 
 | 
 | ||||||
|   var apiUrl = 'https://acme-{{env}}.api.letsencrypt.org/directory'; |   var apiUrl = 'https://acme-{{env}}.api.letsencrypt.org/directory'; | ||||||
| @ -238,7 +243,7 @@ | |||||||
|     if (jwk) { |     if (jwk) { | ||||||
|       p = PromiseA.resolve(jwk); |       p = PromiseA.resolve(jwk); | ||||||
|     } else { |     } else { | ||||||
|       p = createKeypair(); |       p = testKeypairSupport().then(createKeypair); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     function createAccount(jwk) { |     function createAccount(jwk) { | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user