2013-05-23 6 views
5

Sto scrivendo un'app Node.js e sto cercando di integrare un server ADFS per ottenere l'autenticazione. Per questo, sto usando wstrust-client e usando l'URL del server ADFS come mio endpoint. Il mio codice finora è:HTTP 400: errore di richiesta non valido nella richiesta HTTPS di ADFS

app.get('/login', function(req, res) { 
    trustClient.requestSecurityToken({ 
     scope: 'https://mycompany.com', 
     username: "username", 
     password: "password", 
     endpoint: 'https://[adfs server]/adfs/services/trust/13/usernamemixed' 
    }, function (rstr) { 
     // Access the token 
     var rawToken = rstr.token; 
     console.log('raw: ' + rawToken); 
    }, function(error) { 
     console.log(error) 
    }); 
});  

Chiedo https attraverso wstrust-client

Il mio codice in wstrustclient.js finora è:

var req = https.request(post_options, function(res) { 
    res.setEncoding('utf8'); 
    res.on('data', function(data) { 
     console.log("Entered res") 

     var rstr = { 
      token: parseRstr(data), 
      response: res, 
     }; 

     callback(rstr); 
    }); 
}); 

req.write(message); 
req.end(); 
req.on('error', function (e) { 
console.log("******************************"); 
console.log(e); 
console.log("******************************"); 

Tuttavia, si sta gettando questo errore:

****************************** 
{ [Error: UNABLE_TO_VERIFY_LEAF_SIGNATURE] 
    stack: 'Error: UNABLE_TO_VERIFY_LEAF_SIGNATURE\n 
    at SecurePair.<anonymous> (tls.js:1253:32)\n  
    at SecurePair.EventEmitter.emit (events.js:91:17)\n  
    at SecurePair.maybeInitFinished (tls.js:865:10)\n  
    at CleartextStream.read [as _read] (tls.js:416:15)\n 
    at CleartextStream.Readable.read (_stream_readable.js:231:10)\n 
    at EncryptedStream.write [as _write] (tls.js:329:25)\n 
    at EncryptedStream.Writable.write (_stream_writable.js:176:8)\n 
    at write (_stream_readable.js:496:24)\n 
    at flow (_stream_readable.js:506:7)\n  
    at Socket.pipeOnReadable (_stream_readable.js:538:5)' } 
    ****************************** 
    ****************************** 
    { [Error: read ECONNRESET] 
     stack: 'Error: read ECONNRESET\n 
     at errnoException (net.js:846:11)\n 
     at TCP.onread (net.js:508:19)', 
     code: 'ECONNRESET', 
     errno: 'ECONNRESET', 
     syscall: 'read' } 
    ****************************** 

Quando sfoglio lo stesso URL dell'endpoint in un browser, esso genera HTTP 400: Bad Request

So che si tratta di un errore di tipo SSL e che proviene dal lato server. Tuttavia, non so perché sta lanciando l'errore e cosa potrebbe essere sbagliato sul lato server. Cosa devo cambiare?

risposta

4

Come per il manuale di OpenSSL here:

21 X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE: unable to verify the first certificate no signatures could be verified because the chain contains only one certificate and it is not self signed.

Con questo in mente, sembra che potrebbe essere necessario per firmare il certificato.