aboutsummaryrefslogtreecommitdiff
path: root/src/ext/Iis/ca/scassl7.cpp
blob: 47c16a9d23b55f03bcfe50ed33f4dbf4c12c2748 (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
// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.

#include "precomp.h"

HRESULT ScaSslCertificateWrite7(
    __in_z LPCWSTR wzWebBase,
    __in SCA_WEB_SSL_CERTIFICATE* pswscList
    )
{
    HRESULT hr = S_OK;
    WCHAR wzEncodedCertificateHash[CB_CERTIFICATE_HASH * 2 + 1] = { 0 };

    for (SCA_WEB_SSL_CERTIFICATE* pswsc = pswscList; pswsc; pswsc = pswsc->pNext)
    {
        hr = ScaWriteConfigID(IIS_SSL_BINDING);
        ExitOnFailure(hr, "Failed write SSL binding ID");
        hr = ScaWriteConfigID(IIS_CREATE);                      // Need to determine site action
        ExitOnFailure(hr, "Failed write binding action");

        hr = ScaWriteConfigString(wzWebBase);                   //site name key
        ExitOnFailure(hr, "Failed to write SSL website");
        hr = ScaWriteConfigString(pswsc->wzStoreName);          //ssl store name
        ExitOnFailure(hr, "Failed to write SSL store name");

        hr = StrHexEncode(pswsc->rgbSHA1Hash, countof(pswsc->rgbSHA1Hash), wzEncodedCertificateHash, countof(wzEncodedCertificateHash));
        ExitOnFailure(hr, "Failed to encode SSL hash");

        hr = ScaWriteConfigString(wzEncodedCertificateHash);    //ssl hash
        ExitOnFailure(hr, "Failed to write SSL hash");
    }
LExit:

    return hr;
}