summaryrefslogtreecommitdiff
path: root/csharp/src/IceSSL/Util.cs
blob: 7b64a30befc409184a9218b20a7f8006cd7e9087 (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
// **********************************************************************
//
// Copyright (c) 2003-2016 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;
    using System.Diagnostics;
    using System.Security.Cryptography.X509Certificates;

    /// <summary>
    /// This class provides information about a connection to applications
    /// that require information about a peer, for example, to implement
    /// a CertificateVerifier.
    /// </summary>
    public sealed class NativeConnectionInfo : ConnectionInfo
    {
        /// <summary>
        /// The certificate chain. This may be null if the peer did not
        /// supply a certificate. The peer's certificate (if any) is the
        /// first one in the chain.
        /// </summary>
        public System.Security.Cryptography.X509Certificates.X509Certificate2[] nativeCerts;
    }

    /// <summary>
    /// This class provides information about a connection to applications
    /// that require information about a peer.
    /// </summary>
    public sealed class WSSNativeConnectionInfo : WSSConnectionInfo
    {
        /// <summary>
        /// The certificate chain. This may be null if the peer did not
        /// supply a certificate. The peer's certificate (if any) is the
        /// first one in the chain.
        /// </summary>
        public System.Security.Cryptography.X509Certificates.X509Certificate2[] nativeCerts;
    }

    public sealed class Util
    {
        public static X509Certificate2 createCertificate(string certPEM)
        {
            char[] chars = certPEM.ToCharArray();
            byte[] bytes = new byte[chars.Length];
            for(int i = 0; i < chars.Length; ++i)
            {
                bytes[i] = (byte)chars[i];
            }
            return new X509Certificate2(bytes);
        }
    }
}