summaryrefslogtreecommitdiff
path: root/cpp/include/IceSSL/SChannel.h
blob: 3c5908bb8b4d83bbbab07d01e4c6cdf1ce966762 (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
// **********************************************************************
//
// Copyright (c) 2003-2018 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.
//
// **********************************************************************

#ifndef ICESSL_SCHANNEL_H
#define ICESSL_SCHANNEL_H

#ifdef _WIN32

#include <IceSSL/Plugin.h>

#include <wincrypt.h>

namespace IceSSL
{

namespace SChannel
{

class Certificate;
ICE_DEFINE_PTR(CertificatePtr, Certificate);

/**
 * This convenience class is a wrapper around a native certificate.
 * \headerfile IceSSL/IceSSL.h
 */
class ICESSL_API Certificate : public virtual IceSSL::Certificate
{
public:

    /**
     * Constructs a certificate using a native certificate.
     * The Certificate class assumes ownership of the given native
     * certificate.
     * @param info The certificate data.
     * @return The new certificate instance.
     */
    static CertificatePtr create(CERT_SIGNED_CONTENT_INFO* info);

    /**
     * Loads the certificate from a file. The certificate must use the
     * PEM encoding format.
     * @param file The certificate file.
     * @return The new certificate instance.
     * @throws CertificateReadException if the file cannot be read.
     */
    static CertificatePtr load(const std::string& file);

    /**
     * Decodes a certificate from a string that uses the PEM encoding format.
     * @param str A string containing the encoded certificate.
     * @return The new certificate instance.
     * @throws CertificateEncodingException if an error occurs.
     */
    static CertificatePtr decode(const std::string& str);

    /**
     * Obtains the native X509 certificate value wrapped by this object.
     * @return A reference to the native certificate.
     * The returned reference is only valid for the lifetime of this
     * object. The returned reference is a pointer to a struct.
     */
    virtual CERT_SIGNED_CONTENT_INFO* getCert() const = 0;
};

} // SChannel namespace end

} // IceSSL namespace end

#endif

#endif