Implement CONNECT pass-through for HTTPS proxy
* When using a proxy, HTTPS connexion must still go directly to the target website. The proxy can then act as a TCP stream relay and just transmit the raw SSL stream between the client and website. * For this, we ask the proxy sending an HTTP request with the CONNECT method. If the proxy supports this, we can then send anything as the payload and it will be forwarded. * Untested, as the network here in Dusseldorf doesn't let me use a proxy. ticket : #10973
This commit is contained in:
@@ -16,6 +16,12 @@
|
||||
#include <NetworkRequest.h>
|
||||
|
||||
|
||||
namespace BPrivate {
|
||||
class CheckedSecureSocket;
|
||||
class CheckedProxySecureSocket;
|
||||
};
|
||||
|
||||
|
||||
class BHttpRequest : public BNetworkRequest {
|
||||
public:
|
||||
BHttpRequest(const BUrl& url,
|
||||
@@ -76,7 +82,8 @@ private:
|
||||
BString& _ResultStatusText();
|
||||
|
||||
// SSL failure management
|
||||
friend class CheckedSecureSocket;
|
||||
friend class BPrivate::CheckedSecureSocket;
|
||||
friend class BPrivate::CheckedProxySecureSocket;
|
||||
bool _CertificateVerificationFailed(
|
||||
BCertificate& certificate,
|
||||
const char* message);
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright 2015, Haiku, Inc. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _PROXY_SECURE_SOCKET_H
|
||||
#define _PROXY_SECURE_SOCKET_H
|
||||
|
||||
|
||||
#include <SecureSocket.h>
|
||||
|
||||
|
||||
class BProxySecureSocket : public BSecureSocket {
|
||||
public:
|
||||
BProxySecureSocket(const BNetworkAddress& proxy);
|
||||
BProxySecureSocket(const BNetworkAddress& proxy,
|
||||
const BNetworkAddress& peer,
|
||||
bigtime_t timeout = B_INFINITE_TIMEOUT);
|
||||
BProxySecureSocket(const BProxySecureSocket& other);
|
||||
virtual ~BProxySecureSocket();
|
||||
|
||||
// BSocket implementation
|
||||
|
||||
virtual status_t Connect(const BNetworkAddress& peer,
|
||||
bigtime_t timeout = B_INFINITE_TIMEOUT);
|
||||
|
||||
private:
|
||||
const BNetworkAddress fProxyAddress;
|
||||
};
|
||||
|
||||
|
||||
#endif // _PROXY_SECURE_SOCKET_H
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2011, Haiku, Inc. All Rights Reserved.
|
||||
* Copyright 2011-2015, Haiku, Inc. All Rights Reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _SECURE_SOCKET_H
|
||||
@@ -23,6 +23,8 @@ public:
|
||||
virtual bool CertificateVerificationFailed(BCertificate&
|
||||
certificate, const char* message);
|
||||
|
||||
status_t InitCheck();
|
||||
|
||||
// BSocket implementation
|
||||
|
||||
virtual status_t Connect(const BNetworkAddress& peer,
|
||||
@@ -37,6 +39,9 @@ public:
|
||||
virtual ssize_t Read(void* buffer, size_t size);
|
||||
virtual ssize_t Write(const void* buffer, size_t size);
|
||||
|
||||
protected:
|
||||
status_t _Setup();
|
||||
|
||||
private:
|
||||
friend class BCertificate;
|
||||
class Private;
|
||||
|
||||
Reference in New Issue
Block a user