55// global variables
66var //CA = "https://acme-staging.api.letsencrypt.org",
77 CA = "https://acme-v01.api.letsencrypt.org" ,
8- TERMS = "https://letsencrypt.org/documents/LE-SA-v1.1.1-August-1-2016.pdf" ,
98 ACCOUNT_EMAIL , // "bar@foo.com"
109 ACCOUNT_PUBKEY , // {
1110 // "pubkey": "-----BEGIN PUBLIC KEY...",
@@ -108,10 +107,11 @@ function getNonce(callback){
108107 var cachebuster = b64 ( window . crypto . getRandomValues ( new Uint8Array ( 8 ) ) ) ;
109108 var xhr = new XMLHttpRequest ( ) ;
110109 xhr . onload = function ( ) {
111- callback ( xhr . getResponseHeader ( "Replay-Nonce" ) , undefined ) ;
110+ var directory = JSON . parse ( xhr . responseText ) ;
111+ callback ( xhr . getResponseHeader ( "Replay-Nonce" ) , undefined , directory ) ;
112112 } ;
113113 xhr . onerror = function ( ) {
114- callback ( undefined , xhr ) ;
114+ callback ( undefined , xhr , undefined ) ;
115115 } ;
116116 xhr . open ( "GET" , CA + "/directory?cachebuster=" + cachebuster ) ;
117117 xhr . send ( ) ;
@@ -326,17 +326,17 @@ function validateCSR(e){
326326 document . getElementById ( "ssltest_domain" ) . value = shortest_domain ;
327327
328328 //build account registration payload
329- getNonce ( function ( nonce , err ) {
329+ getNonce ( function ( nonce , err , directory ) {
330330 ACCOUNT_PUBKEY [ 'protected' ] = b64 ( JSON . stringify ( { nonce : nonce } ) ) ;
331331 ACCOUNT_PUBKEY [ 'payload' ] = b64 ( JSON . stringify ( {
332332 resource : "new-reg" ,
333333 contact : [ "mailto:" + ACCOUNT_EMAIL ] ,
334- agreement : TERMS ,
334+ agreement : directory [ 'meta' ] [ 'terms-of-service' ] ,
335335 } ) ) ;
336336 } ) ;
337337
338338 //build csr payload
339- getNonce ( function ( nonce , err ) {
339+ getNonce ( function ( nonce , err , directory ) {
340340 CSR [ 'protected' ] = b64 ( JSON . stringify ( { nonce : nonce } ) ) ;
341341 CSR [ 'payload' ] = b64 ( JSON . stringify ( {
342342 resource : "new-cert" ,
@@ -346,7 +346,7 @@ function validateCSR(e){
346346
347347 //build domain payloads
348348 function buildDomain ( domain ) {
349- getNonce ( function ( nonce , err ) {
349+ getNonce ( function ( nonce , err , directory ) {
350350 DOMAINS [ domain ] [ 'request_protected' ] = b64 ( JSON . stringify ( { nonce : nonce } ) ) ;
351351 DOMAINS [ domain ] [ 'request_payload' ] = b64 ( JSON . stringify ( {
352352 resource : "new-authz" ,
0 commit comments