blob: 42d232d7fb351b1334f6e47654e3e25fe955f084 (
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
//
// Copyright (c) ZeroC, Inc. All rights reserved.
//
#ifndef ICESSL_UTIL_H
#define ICESSL_UTIL_H
#include <IceUtil/Mutex.h>
#include <IceUtil/Shared.h>
#include <IceUtil/Handle.h>
#include <IceSSL/Plugin.h>
#if defined(__APPLE__)
# include <CoreFoundation/CoreFoundation.h>
# if TARGET_OS_IPHONE != 0
# define ICE_USE_SECURE_TRANSPORT_IOS 1
# else
# define ICE_USE_SECURE_TRANSPORT_MACOS 1
# endif
#endif
namespace IceSSL
{
#if defined(__APPLE__)
//
// Helper functions to use by Secure Transport.
//
std::string fromCFString(CFStringRef);
inline CFStringRef
toCFString(const std::string& s)
{
return CFStringCreateWithCString(ICE_NULLPTR, s.c_str(), kCFStringEncodingUTF8);
}
#endif
#ifdef ICE_CPP11_MAPPING
//
// Adapts the C++11 functions to C++98-like callbacks
//
class ICESSL_API CertificateVerifier
{
public:
CertificateVerifier(std::function<bool(const std::shared_ptr<ConnectionInfo>&)>);
bool verify(const ConnectionInfoPtr&);
private:
std::function<bool(const std::shared_ptr<ConnectionInfo>&)> _verify;
};
using CertificateVerifierPtr = std::shared_ptr<CertificateVerifier>;
class ICESSL_API PasswordPrompt
{
public:
PasswordPrompt(std::function<std::string()>);
std::string getPassword();
private:
std::function<std::string()> _prompt;
};
using PasswordPromptPtr = std::shared_ptr<PasswordPrompt>;
#endif
//
// Constants for X509 certificate alt names (AltNameOther, AltNameORAddress, AltNameEDIPartyName and
// AltNameObjectIdentifier) are not supported.
//
//const int AltNameOther = 0;
const int AltNameEmail = 1;
const int AltNameDNS = 2;
//const int AltNameORAddress = 3;
const int AltNameDirectory = 4;
//const int AltNameEDIPartyName = 5;
const int AltNameURL = 6;
const int AltNAmeIP = 7;
//const AltNameObjectIdentifier = 8;
//
// Read a file into memory buffer.
//
ICESSL_API void readFile(const std::string&, std::vector<char>&);
//
// Determine if a file or directory exists, with an optional default
// directory.
//
ICESSL_API bool checkPath(const std::string&, const std::string&, bool, std::string&);
ICESSL_API bool parseBytes(const std::string&, std::vector<unsigned char>&);
}
#endif
|