Bonjour,

J'ai developpe un proxy qui fonctionne tres bien en HTTP.

J'ai reglé sur firefox le port pour le proxy.
Le client se connecte
je recupere les infos hostname et port du client que je redirige vers le seveur http de destination
je recpere les donnees du serveur destinataire que je revoie au client, ca c'est le principe du proxy.

Par contre pour une url https j'ai un probleme, car comme c'est chiffré, je ne peux pas recuperer le hostname et le port pour rediriger l'url vers le serveur https destinataire.

Pour les connexions https j'utilise "connectToHostEncrypted" et dans le signal encrypted j'envoie les donnees au serveur https destinataire.

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
 
void MyThread::doSslConnect(const QByteArray &databyte)
{   
    socket_proxy = new QSslSocket();
 
    if (!socket_proxy->supportsSsl()) {
        emit appendSignalText("SSL is not supported by your version of Qt. You must obtain a version of Qt", Qt::red);
        delete socket_proxy;
        return;
    }
 
    connect(socket_proxy, SIGNAL(connected()),this, SLOT(connectedProxy()), Qt::DirectConnection);
    connect(socket_proxy, SIGNAL(disconnected()),this, SLOT(disconnectedProxy()), Qt::DirectConnection);
    connect(socket_proxy, SIGNAL(readyRead()),this, SLOT(readyReadProxySsl()), Qt::DirectConnection);
    connect(socket_proxy, SIGNAL(error(QAbstractSocket::SocketError)),this, SLOT(displayError(QAbstractSocket::SocketError)), Qt::DirectConnection);
    connect( socket_proxy, SIGNAL(sslErrors(const QList<QSslError> &)), this, SLOT(sslError(const QList<QSslError> &)), Qt::DirectConnection );
    connect(socket_proxy, SIGNAL(encrypted()), this, SLOT(ready()), Qt::DirectConnection );
    connect(socket_proxy, SIGNAL(modeChanged(QSslSocket::SslMode)), this, SLOT(SslModeChanged(QSslSocket::SslMode)), Qt::DirectConnection );
    connect(socket_proxy, SIGNAL(stateChanged(QAbstractSocket::SocketState)), this, SLOT(SslStateChanged(QAbstractSocket::SocketState)), Qt::DirectConnection );
 
    socket_proxy->abort();
 
    //Connect to host
    socket_proxy->connectToHostEncrypted(QString(Hostname), Port.toInt());
 
    if (!socket_proxy->waitForEncrypted(10000)) {
        emit appendSignalText(tr("Encrypted data error: %1").arg(socket_proxy->errorString()), Qt::red);
        return;
    }
 
}
Comment je peux faire ?

Merci de votre aide.