summaryrefslogtreecommitdiffstats
path: root/blimp/net/ssl_client_transport.h
blob: 0f0a1f4a7a5f62219742eb918990b24ab23ee60a (plain)
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef BLIMP_NET_SSL_CLIENT_TRANSPORT_H_
#define BLIMP_NET_SSL_CLIENT_TRANSPORT_H_

#include <string>
#include "base/callback_forward.h"
#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "blimp/net/blimp_net_export.h"
#include "blimp/net/blimp_transport.h"
#include "blimp/net/exact_match_cert_verifier.h"
#include "blimp/net/tcp_client_transport.h"
#include "net/base/address_list.h"
#include "net/base/net_errors.h"
#include "net/http/transport_security_state.h"

namespace net {
class ClientSocketFactory;
class NetLog;
class StreamSocket;
class TCPClientSocket;
class TransportSecurityState;
}  // namespace net

namespace blimp {

class BlimpConnection;

// Creates and connects SSL socket connections to an Engine.
class BLIMP_NET_EXPORT SSLClientTransport : public TCPClientTransport {
 public:
  // |ip_endpoint|: the address to connect to.
  // |cert|: the certificate required from the remote peer.
  //     SSL connections that use different certificates are rejected.
  // |net_log|: the socket event log (optional).
  SSLClientTransport(const net::IPEndPoint& ip_endpoint,
                     scoped_refptr<net::X509Certificate> cert,
                     net::NetLog* net_log);

  ~SSLClientTransport() override;

  // BlimpTransport implementation.
  const char* GetName() const override;

 private:
  // Method called after TCPClientSocket::Connect finishes.
  void OnTCPConnectComplete(int result) override;

  // Method called after SSLClientSocket::Connect finishes.
  void OnSSLConnectComplete(int result);

  net::IPEndPoint ip_endpoint_;
  scoped_ptr<ExactMatchCertVerifier> cert_verifier_;
  net::TransportSecurityState transport_security_state_;

  DISALLOW_COPY_AND_ASSIGN(SSLClientTransport);
};

}  // namespace blimp

#endif  // BLIMP_NET_SSL_CLIENT_TRANSPORT_H_