summaryrefslogtreecommitdiffstats
blob: b8d372825dd72dbc39468e5185468bb9fe6f04a0 (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
/*
 * Copyright (c) 2015 Isode Limited.
 * All rights reserved.
 * See the COPYING file for more information.
 */

#pragma once

#include <boost/shared_ptr.hpp>
#include <boost/type_traits.hpp>

#include <Security/SecCertificate.h>

#include <Swiften/TLS/Certificate.h>

namespace Swift {

class SecureTransportCertificate : public Certificate {
public:
	SecureTransportCertificate(SecCertificateRef certificate);
	SecureTransportCertificate(const ByteArray& der);
	virtual ~SecureTransportCertificate();

	virtual std::string getSubjectName() const;
	virtual std::vector<std::string> getCommonNames() const;
	virtual std::vector<std::string> getSRVNames() const;
	virtual std::vector<std::string> getDNSNames() const;
	virtual std::vector<std::string> getXMPPAddresses() const;

	virtual ByteArray toDER() const;

private:
	void parse();
	typedef boost::remove_pointer<SecCertificateRef>::type SecCertificate;

private:
	boost::shared_ptr<SecCertificate> certificateHandle_;
	std::string subjectName_;
	std::vector<std::string> commonNames_;
	std::vector<std::string> srvNames_;
	std::vector<std::string> dnsNames_;
	std::vector<std::string> xmppAddresses_;
};

}