2017-06-16 11 views
0

J'essaie d'obtenir la page https avec le certificat SSL côté client, avec Indy TIdHTTP.Indy TIdHTTP obtenir la page https avec le certificat SSL côté client

code

est

var IdHTTP1 : TIdHTTP; 
    IdSSLIOHandlerSocket : TIdSSLIOHandlerSocketOpenSSL; 
begin 
    try 
     IdHTTP1 := TIdHTTP.Create(self); 
     IdHTTP1.Request.BasicAuthentication := False; 
     IdHTTP1.Request.UserAgent := 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20100101 Firefox/12.0'; 
     IdSSLIOHandlerSocket := TIdSSLIOHandlerSocketOpenSSL.Create(IdHTTP1); 
     IdSSLIOHandlerSocket.SSLOptions.CertFile := 'cert.pem'; 
     IdSSLIOHandlerSocket.SSLOptions.Method := sslvTLSv1_2; 
     IdSSLIOHandlerSocket.SSLOptions.Mode:= sslmUnassigned; 

     IdHTTP1.IOHandler := IdSSLIOHandlerSocket; 

     writeln(IdHTTP1.Get('https://www.scriptjunkie.us/auth/verifycert')); 
    finally 
     IdSSLIOHandlerSocket.Free; 
     IdHTTP1.Free; 
    end; 

Get n'est pas authentifiez. Le certificat PEM du client n'est pas accepté.

Comment obtenir l'URL avec le client cert?

J'ai utilisé le site https://www.scriptjunkie.us/auth/verifycert avec SSL côté client certifié. CPF est 3.0.2, Indy est 10.6.2.0

+0

Quel est le problème réel * *? Est-ce que 'Get' relance une exception? Si oui, que dit-il? Pourquoi utilisez-vous un certificat client en premier lieu? Le serveur répond-il uniquement aux clients authentifiés? Êtes-vous en mesure d'accéder au serveur avec un navigateur Web standard? –

+0

@Remy Lebeau Oui, le problème est réel. Je lui fais face avec la dernière version d'Indy (de dev svn). Les exceptions ne sont pas risquées, le serveur renvoie simplement du contenu non autorisé. Si j'utilise FireFox et le certificat d'importation - tout fonctionne correctement (voir les liens dans ma question) –

+0

quoi. Si 'Get' ne déclenche pas d'erreur, ni HTTP ni SSL ne tombent en panne. Qu'est-ce qui vous fait penser que c'est un problème SSL, et pas simplement un problème d'authentification d'utilisateur? Le serveur a-t-il besoin d'un client pour se connecter, soit par authentification HTTP, soit par authentification Web HTML? –

Répondre

0

Voici un code de travail (Indy 10.6.2.0, CPF 3.0.2)

uses IdHTTP, IdSSLOpenSSL; 

var IdHTTP1 : TIdHTTP; 
    Id_HandlerSocket : TIdSSLIOHandlerSocketOpenSSL; 
    s : string; 

begin 
    try 
     IdHTTP1 := TIdHTTP.Create(self); 
     IdHTTP1.Request.BasicAuthentication := False; 
     IdHTTP1.Request.UserAgent := 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20100101 Firefox/12.0'; 
     Id_HandlerSocket := TIdSSLIOHandlerSocketOpenSSL.Create(IdHTTP1); 
     cert := 'my_scriptjunkie_pem.pem'; 
     Id_HandlerSocket.SSLOptions.CertFile := cert; (* PEM contain both CERT and Key *) 
     Id_HandlerSocket.SSLOptions.KeyFile := cert; 

     Id_HandlerSocket.SSLOptions.Mode := sslmClient; 
     Id_HandlerSocket.SSLOptions.Method := sslvSSLv23; 
     IdHTTP1.IOHandler := Id_HandlerSocket; 

     WriteLn(Id_HandlerSocket.SSLOptions.CertFile); 

     s := IdHTTP1.Get('https://www.scriptjunkie.us/auth/verifycert'); 

     writeln(s); 

    finally 
     Id_HandlerSocket.Free; 
     IdHTTP1.Free; 
    end;  
end;