/src/mozilla-central/netwerk/base/TLSServerSocket.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* vim:set ts=2 sw=2 et cindent: */ |
2 | | /* This Source Code Form is subject to the terms of the Mozilla Public |
3 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
4 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
5 | | |
6 | | #ifndef mozilla_net_TLSServerSocket_h |
7 | | #define mozilla_net_TLSServerSocket_h |
8 | | |
9 | | #include "nsAutoPtr.h" |
10 | | #include "nsITLSServerSocket.h" |
11 | | #include "nsServerSocket.h" |
12 | | #include "nsString.h" |
13 | | #include "mozilla/Mutex.h" |
14 | | #include "seccomon.h" |
15 | | |
16 | | namespace mozilla { |
17 | | namespace net { |
18 | | |
19 | | class TLSServerSocket final : public nsServerSocket |
20 | | , public nsITLSServerSocket |
21 | | { |
22 | | public: |
23 | | NS_DECL_ISUPPORTS_INHERITED |
24 | | NS_FORWARD_NSISERVERSOCKET(nsServerSocket::) |
25 | | NS_DECL_NSITLSSERVERSOCKET |
26 | | |
27 | | // Override methods from nsServerSocket |
28 | | virtual void CreateClientTransport(PRFileDesc* clientFD, |
29 | | const NetAddr& clientAddr) override; |
30 | | virtual nsresult SetSocketDefaults() override; |
31 | | virtual nsresult OnSocketListen() override; |
32 | | |
33 | | TLSServerSocket(); |
34 | | |
35 | | private: |
36 | 0 | virtual ~TLSServerSocket() = default; |
37 | | |
38 | | static SECStatus AuthCertificateHook(void* arg, PRFileDesc* fd, |
39 | | PRBool checksig, PRBool isServer); |
40 | | |
41 | | nsCOMPtr<nsIX509Cert> mServerCert; |
42 | | }; |
43 | | |
44 | | class TLSServerConnectionInfo : public nsITLSServerConnectionInfo |
45 | | , public nsITLSClientStatus |
46 | | { |
47 | | friend class TLSServerSocket; |
48 | | |
49 | | public: |
50 | | NS_DECL_THREADSAFE_ISUPPORTS |
51 | | NS_DECL_NSITLSSERVERCONNECTIONINFO |
52 | | NS_DECL_NSITLSCLIENTSTATUS |
53 | | |
54 | | TLSServerConnectionInfo(); |
55 | | |
56 | | private: |
57 | | virtual ~TLSServerConnectionInfo(); |
58 | | |
59 | | static void HandshakeCallback(PRFileDesc* aFD, void* aArg); |
60 | | nsresult HandshakeCallback(PRFileDesc* aFD); |
61 | | |
62 | | RefPtr<TLSServerSocket> mServerSocket; |
63 | | // Weak ref to the transport, to avoid cycles since the transport holds a |
64 | | // reference to the TLSServerConnectionInfo object. This is not handed out to |
65 | | // anyone, and is only used in HandshakeCallback to close the transport in |
66 | | // case of an error. After this, it's set to nullptr. |
67 | | nsISocketTransport* mTransport; |
68 | | nsCOMPtr<nsIX509Cert> mPeerCert; |
69 | | int16_t mTlsVersionUsed; |
70 | | nsCString mCipherName; |
71 | | uint32_t mKeyLength; |
72 | | uint32_t mMacLength; |
73 | | // lock protects access to mSecurityObserver |
74 | | mozilla::Mutex mLock; |
75 | | nsCOMPtr<nsITLSServerSecurityObserver> mSecurityObserver; |
76 | | }; |
77 | | |
78 | | } // namespace net |
79 | | } // namespace mozilla |
80 | | |
81 | | #endif // mozilla_net_TLSServerSocket_h |