summaryrefslogtreecommitdiff
path: root/cpp/src/IceSSL/SSLEngine.h
blob: 9251634683157da1803abd2516d9f9045f5b0c93 (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
//
// Copyright (c) ZeroC, Inc. All rights reserved.
//

#ifndef ICESSL_ENGINE_H
#define ICESSL_ENGINE_H

#include <IceSSL/Plugin.h>
#include <IceSSL/Util.h>
#include <IceSSL/SSLEngineF.h>
#include <IceSSL/TrustManagerF.h>
#include <IceSSL/InstanceF.h>

#include <IceUtil/Shared.h>
#include <Ice/CommunicatorF.h>
#include <Ice/Network.h>
#include <Ice/TransceiverF.h>

namespace IceSSL
{

class ICESSL_API SSLEngine : public IceUtil::Shared
{
public:

    SSLEngine(const Ice::CommunicatorPtr&);

    Ice::CommunicatorPtr communicator() const { return _communicator; }
    Ice::LoggerPtr getLogger() const { return _logger; };

    void setCertificateVerifier(const CertificateVerifierPtr&);
    void setPasswordPrompt(const PasswordPromptPtr&);
    std::string password(bool);

    //
    // Setup the engine.
    //
    virtual void initialize() = 0;

    virtual bool initialized() const;

    //
    // Destroy the engine.
    //
    virtual void destroy() = 0;

    //
    // Create a transceiver using the engine specific implementation
    //
    virtual IceInternal::TransceiverPtr
    createTransceiver(const InstancePtr&, const IceInternal::TransceiverPtr&, const std::string&, bool) = 0;

    //
    // Verify peer certificate
    //
    virtual void verifyPeer(const std::string&, const ConnectionInfoPtr&, const std::string&);
    void verifyPeerCertName(const std::string&, const ConnectionInfoPtr&);

    CertificateVerifierPtr getCertificateVerifier() const;
    PasswordPromptPtr getPasswordPrompt() const;

    std::string getPassword() const;
    void setPassword(const std::string& password);

    bool getCheckCertName() const;
    bool getServerNameIndication() const;
    int getVerifyPeer() const;
    int securityTraceLevel() const;
    std::string securityTraceCategory() const;

protected:

    bool _initialized;
    IceUtil::Mutex _mutex;

private:

    const Ice::CommunicatorPtr _communicator;
    const Ice::LoggerPtr _logger;
    const TrustManagerPtr _trustManager;

    std::string _password;
    CertificateVerifierPtr _verifier;
    PasswordPromptPtr _prompt;

    bool _checkCertName;
    bool _serverNameIndication;
    int _verifyDepthMax;
    int _verifyPeer;
    int _securityTraceLevel;
    std::string _securityTraceCategory;
};

}

#endif