Win32 API 日本語リファレンス
ホームNetworking.WindowsWebServices › WS_THUMBPRINT_CERT_CREDENTIAL

WS_THUMBPRINT_CERT_CREDENTIAL

構造体
サイズx64: 40 バイト / x86: 24 バイト

サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。

フィールド

フィールドサイズx64x86説明
credentialWS_CERT_CREDENTIAL4+0+0この型および他のすべての証明書資格情報の型が派生する基本型です。
storeLocationDWORD4+4+4指定された証明書が格納されている証明書ストアの場所 (CERT_SYSTEM_STORE_CURRENT_USERCERT_SYSTEM_STORE_LOCAL_MACHINE など) です。
storeNameWS_STRING16/8+8+8指定された証明書が格納されている証明書ストアの名前 ("My" など) です。
thumbprintWS_STRING16/8+24+16指定された証明書の SHA-1 拇印 ("c0f89c8d4e4e80f250b58c3fae944a0edee02804" など) です。指定する値は、 空白文字や先頭の 0x を含まない 16 進数の文字列でなければなりません。 証明書の拇印を調べるには、certmgr.exe などのツールを使用できます。

公式ドキュメント

証明書の拇印 (サムプリント)、ストアの場所、ストア名を使用して証明書資格情報を 指定するための型です。指定された資格情報は、それを含むチャネルまたは リスナーが開かれるときに読み込まれます。

指定する証明書ストアにサブジェクト名が一致する証明書が複数存在するために、 サブジェクト名による指定があいまいになると予想される場合、拇印は証明書を 指定する最適な方法です。

出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)

各言語での定義

#include <windows.h>

// WS_CERT_CREDENTIAL  (x64 4 / x86 4 バイト)
typedef struct WS_CERT_CREDENTIAL {
    WS_CERT_CREDENTIAL_TYPE credentialType;
} WS_CERT_CREDENTIAL;

// WS_STRING  (x64 16 / x86 8 バイト)
typedef struct WS_STRING {
    DWORD length;
    LPWSTR chars;
} WS_STRING;

// WS_THUMBPRINT_CERT_CREDENTIAL  (x64 40 / x86 24 バイト)
typedef struct WS_THUMBPRINT_CERT_CREDENTIAL {
    WS_CERT_CREDENTIAL credential;
    DWORD storeLocation;
    WS_STRING storeName;
    WS_STRING thumbprint;
} WS_THUMBPRINT_CERT_CREDENTIAL;
using System;
using System.Runtime.InteropServices;

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct WS_CERT_CREDENTIAL
{
    public int credentialType;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct WS_STRING
{
    public uint length;
    public IntPtr chars;
}

[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct WS_THUMBPRINT_CERT_CREDENTIAL
{
    public WS_CERT_CREDENTIAL credential;
    public uint storeLocation;
    public WS_STRING storeName;
    public WS_STRING thumbprint;
}
Imports System.Runtime.InteropServices

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure WS_CERT_CREDENTIAL
    Public credentialType As Integer
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure WS_STRING
    Public length As UInteger
    Public chars As IntPtr
End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure WS_THUMBPRINT_CERT_CREDENTIAL
    Public credential As WS_CERT_CREDENTIAL
    Public storeLocation As UInteger
    Public storeName As WS_STRING
    Public thumbprint As WS_STRING
End Structure
import ctypes
from ctypes import wintypes

class WS_CERT_CREDENTIAL(ctypes.Structure):
    _fields_ = [
        ("credentialType", ctypes.c_int),
    ]

class WS_STRING(ctypes.Structure):
    _fields_ = [
        ("length", wintypes.DWORD),
        ("chars", ctypes.c_void_p),
    ]

class WS_THUMBPRINT_CERT_CREDENTIAL(ctypes.Structure):
    _fields_ = [
        ("credential", WS_CERT_CREDENTIAL),
        ("storeLocation", wintypes.DWORD),
        ("storeName", WS_STRING),
        ("thumbprint", WS_STRING),
    ]
#[repr(C)]
pub struct WS_CERT_CREDENTIAL {
    pub credentialType: i32,
}

#[repr(C)]
pub struct WS_STRING {
    pub length: u32,
    pub chars: *mut core::ffi::c_void,
}

#[repr(C)]
pub struct WS_THUMBPRINT_CERT_CREDENTIAL {
    pub credential: WS_CERT_CREDENTIAL,
    pub storeLocation: u32,
    pub storeName: WS_STRING,
    pub thumbprint: WS_STRING,
}
import "golang.org/x/sys/windows"

type WS_CERT_CREDENTIAL struct {
	credentialType int32
}

type WS_STRING struct {
	length uint32
	chars uintptr
}

type WS_THUMBPRINT_CERT_CREDENTIAL struct {
	credential WS_CERT_CREDENTIAL
	storeLocation uint32
	storeName WS_STRING
	thumbprint WS_STRING
}
type
  WS_CERT_CREDENTIAL = record
    credentialType: Integer;
  end;

  WS_STRING = record
    length: DWORD;
    chars: Pointer;
  end;

  WS_THUMBPRINT_CERT_CREDENTIAL = record
    credential: WS_CERT_CREDENTIAL;
    storeLocation: DWORD;
    storeName: WS_STRING;
    thumbprint: WS_STRING;
  end;
const WS_CERT_CREDENTIAL = extern struct {
    credentialType: i32,
};

const WS_STRING = extern struct {
    length: u32,
    chars: ?*anyopaque,
};

const WS_THUMBPRINT_CERT_CREDENTIAL = extern struct {
    credential: WS_CERT_CREDENTIAL,
    storeLocation: u32,
    storeName: WS_STRING,
    thumbprint: WS_STRING,
};
type
  WS_CERT_CREDENTIAL {.bycopy.} = object
    credentialType: int32

  WS_STRING {.bycopy.} = object
    length: uint32
    chars: pointer

  WS_THUMBPRINT_CERT_CREDENTIAL {.bycopy.} = object
    credential: WS_CERT_CREDENTIAL
    storeLocation: uint32
    storeName: WS_STRING
    thumbprint: WS_STRING
struct WS_CERT_CREDENTIAL
{
    int credentialType;
}

struct WS_STRING
{
    uint length;
    void* chars;
}

struct WS_THUMBPRINT_CERT_CREDENTIAL
{
    WS_CERT_CREDENTIAL credential;
    uint storeLocation;
    WS_STRING storeName;
    WS_STRING thumbprint;
}

HSP用 定義

HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。

; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; WS_THUMBPRINT_CERT_CREDENTIAL サイズ: 24 バイト(x86)
dim st, 6    ; 4byte整数×6(構造体サイズ 24 / 4 切り上げ)
; credential : WS_CERT_CREDENTIAL (+0, 4byte)  varptr(st)+0 を基点に操作(4byte:入れ子/配列)
; storeLocation : DWORD (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; storeName : WS_STRING (+8, 8byte)  varptr(st)+8 を基点に操作(8byte:入れ子/配列)
; thumbprint : WS_STRING (+16, 8byte)  varptr(st)+16 を基点に操作(8byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; WS_THUMBPRINT_CERT_CREDENTIAL サイズ: 40 バイト(x64)
dim st, 10    ; 4byte整数×10(構造体サイズ 40 / 4 切り上げ)
; credential : WS_CERT_CREDENTIAL (+0, 4byte)  varptr(st)+0 を基点に操作(4byte:入れ子/配列)
; storeLocation : DWORD (+4, 4byte)  st.1 = 値  /  値 = st.1   (lpoke/lpeek も可)
; storeName : WS_STRING (+8, 16byte)  varptr(st)+8 を基点に操作(16byte:入れ子/配列)
; thumbprint : WS_STRING (+24, 16byte)  varptr(st)+24 を基点に操作(16byte:入れ子/配列)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。
; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
; ※GUID・入れ子構造体はデフォルト型でないため、依存する #defstruct を先に定義(下記に同梱)。
#defstruct global WS_CERT_CREDENTIAL
    #field int credentialType
#endstruct

#defstruct global WS_STRING
    #field int length
    #field intptr chars
#endstruct

#defstruct global WS_THUMBPRINT_CERT_CREDENTIAL
    #field WS_CERT_CREDENTIAL credential
    #field int storeLocation
    #field WS_STRING storeName
    #field WS_STRING thumbprint
#endstruct

stdim st, WS_THUMBPRINT_CERT_CREDENTIAL        ; NSTRUCT 変数を確保
st->storeLocation = 100
mes "storeLocation=" + st->storeLocation