summaryrefslogtreecommitdiffstats
blob: 95fb9292fe61c9d17828e58877f0872c489b2e34 (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
/*
 * Copyright (c) 2012 Tobias Markmann
 * Licensed under the simplified BSD license.
 * See Documentation/Licenses/BSD-simplified.txt for more information. 
 */

#pragma once

#include <Security/SecureTransport.h>
#include <Swiften/Base/boost_bsignals.h>
#include <boost/noncopyable.hpp>

#include <Swiften/TLS/TLSContext.h>
#include <Swiften/Base/ByteArray.h>
#include <Swiften/TLS/CertificateWithKey.h>

namespace Swift {

	class SecureTransportContext : public TLSContext, boost::noncopyable {
		public:
			SecureTransportContext();
			~SecureTransportContext();

			void connect();
			bool setClientCertificate(CertificateWithKey::ref cert);

			void handleDataFromNetwork(const SafeByteArray&);
			void handleDataFromApplication(const SafeByteArray&);

			std::vector<Certificate::ref> getPeerCertificateChain() const;
			boost::shared_ptr<CertificateVerificationError> getPeerCertificateVerificationError() const;

			virtual ByteArray getFinishMessage() const;


		private:
			enum State { Start, Connecting, Connected, Error };

			State state_;

	};
}