@ -365,17 +365,18 @@ module.exports.create = function (gl) {
//
certReq . setChallenge = function ( challenge , done ) {
log ( args . debug , "setChallenge called for '" + challenge . altname + "'" ) ;
// NOTE: First arg takes precedence
var copy = utils . merge ( { domains : [ challenge . altname ] } , args ) ;
copy = utils . merge ( copy , gl ) ;
utils . tplCopy ( copy ) ;
copy . challenge = challenge ;
if ( 1 === gl . challenges [ challenge . type ] . set . length ) {
gl . challenges [ challenge . type ] . set ( copy ) . then ( function ( result ) {
if ( 1 === copy . challenges [ challenge . type ] . set . length ) {
copy . challenges [ challenge . type ] . set ( copy ) . then ( function ( result ) {
done ( null , result ) ;
} ) . catch ( done ) ;
} else if ( 2 === gl . challenges [ challenge . type ] . set . length ) {
gl . challenges [ challenge . type ] . set ( copy , done ) ;
} else if ( 2 === copy . challenges [ challenge . type ] . set . length ) {
copy . challenges [ challenge . type ] . set ( copy , done ) ;
} else {
Object . keys ( challenge ) . forEach ( function ( key ) {
done [ key ] = challenge [ key ] ;
@ -383,28 +384,42 @@ module.exports.create = function (gl) {
// regression bugfix for le-challenge-cloudflare
// (_acme-challege => _greenlock-dryrun-XXXX)
copy . acmePrefix = ( challenge . dnsHost || '' ) . replace ( /\.*/ , '' ) || copy . acmePrefix ;
gl . challenges [ challenge . type ] . set ( copy , challenge . altname , challenge . token , challenge . keyAuthorization , done ) ;
copy . challenges [ challenge . type ] . set ( copy , challenge . altname , challenge . token , challenge . keyAuthorization , done ) ;
}
} ;
certReq . removeChallenge = function ( challenge , done ) {
log ( args . debug , "removeChallenge called for '" + challenge . altname + "'" ) ;
var copy = utils . merge ( { domains : [ challenge . altname ] } , gl ) ;
var copy = utils . merge ( { domains : [ challenge . altname ] } , args ) ;
copy = utils . merge ( copy , gl ) ;
utils . tplCopy ( copy ) ;
copy . challenge = challenge ;
if ( 1 === gl . challenges [ challenge . type ] . remove . length ) {
gl . challenges [ challenge . type ] . remove ( copy ) . then ( function ( result ) {
if ( 1 === copy . challenges [ challenge . type ] . remove . length ) {
copy . challenges [ challenge . type ] . remove ( copy ) . then ( function ( result ) {
done ( null , result ) ;
} ) . catch ( done ) ;
} else if ( 2 === gl . challenges [ challenge . type ] . remove . length ) {
gl . challenges [ challenge . type ] . remove ( copy , done ) ;
} else if ( 2 === copy . challenges [ challenge . type ] . remove . length ) {
copy . challenges [ challenge . type ] . remove ( copy , done ) ;
} else {
Object . keys ( challenge ) . forEach ( function ( key ) {
done [ key ] = challenge [ key ] ;
} ) ;
gl . challenges [ challenge . type ] . remove ( copy , challenge . altname , challenge . token , done ) ;
copy . challenges [ challenge . type ] . remove ( copy , challenge . altname , challenge . token , done ) ;
}
} ;
certReq . getZones = function ( challenge ) {
var copy = utils . merge ( { dnsHosts : args . domains . map ( function ( x ) { return 'xxxx.' + x ; } ) } , args ) ;
copy = utils . merge ( copy , gl ) ;
utils . tplCopy ( copy ) ;
copy . challenge = challenge ;
if ( ! copy . challenges [ challenge . type ] || ( 'function' !== typeof copy . challenges [ challenge . type ] . zones ) ) {
// may not be available, that's fine.
return Promise . resolve ( [ ] ) ;
}
return copy . challenges [ challenge . type ] . zones ( copy ) ;
} ;
log ( args . debug , 'calling greenlock.acme.getCertificateAsync' , certReq . subject , certReq . domains ) ;