summaryrefslogtreecommitdiff
path: root/cs/src/IceSSL/Plugin.cs
blob: e5739bc07b35076410e498d69daa215b1ea6310e (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
// **********************************************************************
//
// Copyright (c) 2003-2009 ZeroC, Inc. All rights reserved.
//
// This copy of Ice is licensed to you under the terms described in the
// ICE_LICENSE file included in this distribution.
//
// **********************************************************************

namespace IceSSL
{
    using System.Security;
    using System.Security.Cryptography.X509Certificates;

    //
    // An application can customize the certificate verification process
    // by implementing the CertificateVerifier interface.
    //
    public interface CertificateVerifier
    {
        //
        // Return true to allow a connection using the provided certificate
        // information, or false to reject the connection.
        //
        bool verify(ConnectionInfo info);
    }

    //
    // A password callback is an alternate way of supplying the plugin with
    // passwords that avoids using plaintext configuration properties.
    //
    public interface PasswordCallback
    {
        //
        // Obtain the password necessary to access the private key associated with
        // the certificate in the given file. Return null if no password is necessary.
        //
        SecureString getPassword(string file);

        //
        // Obtain a password for a certificate being imported via an IceSSL.ImportCert
        // property. Return null if no password is necessary.
        //
        SecureString getImportPassword(string file);
    }

    abstract public class Plugin : Ice.Plugin
    {
        //
        // From Ice.Plugin.
        //
        abstract public void initialize();

        //
        // Specify the certificates to use for SSL connections. This
        // must be done before the plugin is initialized, therefore
        // the application must define the property Ice.InitPlugins=0,
        // set the certificates, and finally invoke initializePlugins
        // on the PluginManager.
        //
        // When the application supplies its own certificates, the
        // plugin skips its normal property-based configuration.
        //
        abstract public void setCertificates(X509Certificate2Collection certs);

        //
        // Establish the certificate verifier object. This should be
        // done before any connections are established.
        //
        abstract public void setCertificateVerifier(CertificateVerifier verifier);

        //
        // Obtain the certificate verifier object. Returns null if no verifier
        // is set.
        //
        abstract public CertificateVerifier getCertificateVerifier();

        //
        // Establish the password callback object. This should be
        // done before the plugin is initialized.
        //
        abstract public void setPasswordCallback(PasswordCallback callback);

        //
        // Obtain the password callback object. Returns null if no callback
        // is set.
        //
        abstract public PasswordCallback getPasswordCallback();

        //
        // This method is for internal use.
        //
        abstract public void destroy();
    }
}