SCHANNEL_CRED
構造体サイズ=各フィールドのバイト数(x64/x86 で異なる場合は x64/x86 と併記)。x64/x86 列=フィールドのバイトオフセット(HSPで dupptr / lpoke / wpoke 等に使用)。
フィールド
| フィールド | 型 | サイズ | x64 | x86 | 説明 | ||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| dwVersion | DWORD | 4 | +0 | +0 | SCHANNEL_CRED_VERSION を設定します。 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| cCreds | DWORD | 4 | +4 | +4 | paCred 配列内の構造体の数です。 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| paCred | CERT_CONTEXT** | 8/4 | +8 | +8 | CERT_CONTEXT 構造体へのポインターの配列です。各ポインターは、アプリケーションの認証に使用する秘密キーを含む証明書を指定します。通常、この配列にはアプリケーションがサポートするキー交換方式ごとに 1 つの構造体が含まれます。 クライアントアプリケーションは、空のリストを渡して適切な証明書の検索を Schannel に任せるか、必要になった時点で後から証明書を作成することがよくあります。 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| hRootStore | HCERTSTORE | 8/4 | +16 | +12 | 省略可能です。サーバーアプリケーションでのみ有効です。アプリケーションが信頼する証明機関 (CA) の自己署名ルート証明書を格納する証明書ストアへのハンドルです。このメンバーは、クライアント認証を必要とするサーバー側アプリケーションでのみ使用されます。 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| cMappers | DWORD | 4 | +24 | +16 | 予約済みです。 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| aphMappers | _HMAPPER** | 8/4 | +32 | +20 | 予約済みです。 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| cSupportedAlgs | DWORD | 4 | +40 | +24 | palgSupportedAlgs 配列内のアルゴリズムの数です。 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| palgSupportedAlgs | ALG_ID* | 8/4 | +48 | +28 | 省略可能です。この構造体を使用して取得した資格情報による接続でサポートされるアルゴリズムを表す ALG_ID アルゴリズム識別子の配列へのポインターです。cSupportedAlgs が 0 の場合、または palgSupportedAlgs が NULL の場合、Schannel はシステムの既定値を使用します。 現在、アルゴリズム識別子 CALG_AES、 CALG_AES_128、 CALG_AES_256 はサポートされていません。 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| grbitEnabledProtocols | DWORD | 4 | +56 | +32 | 省略可能です。この構造体を使用して取得した資格情報による接続でサポートされるプロトコルを表すビット文字列を格納する DWORD です。このメンバーが 0 の場合、Schannel がプロトコルを選択します。新規開発では、アプリケーションは grbitEnabledProtocols を 0 に設定し、システムで既定として有効になっているプロトコルバージョンを使用してください。 このメンバーは、Microsoft Unified Security Protocol Provider セキュリティパッケージでのみ使用されます。 システム全体のレジストリ設定は、この値よりも優先されます。たとえば、レジストリで SSL3 が無効になっている場合、このメンバーを使用して有効にすることはできません。 このメンバーには、次のいずれかのフラグを指定できます。
| ||||||||||||||||||||||||||||||||||||||||||||||||||
| dwMinimumCipherStrength | DWORD | 4 | +60 | +36 | 接続に許可される最小のバルク暗号化強度 (ビット単位) です。 このメンバーが 0 の場合、Schannel はシステムの既定値を使用します。このメンバーが –1 の場合、SSL3/TLS の MAC のみの暗号スイート (NULL 暗号とも呼ばれます) だけが有効になります。 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| dwMaximumCipherStrength | DWORD | 4 | +64 | +40 | 接続に許可される最大のバルク暗号化強度 (ビット単位) です。 このメンバーが 0 の場合、Schannel はシステムの既定値を使用します。 このメンバーが –1 の場合、SSL3/TLS の MAC のみの暗号スイート (NULL 暗号とも呼ばれます) だけが有効になります。この場合、dwMinimumCipherStrength を –1 に設定しなければなりません。 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| dwSessionLifespan | DWORD | 4 | +68 | +44 | Schannel がセッションをセッションキャッシュに保持するミリ秒数です。この時間が経過すると、クライアントとサーバー間の新しい接続には新しい Schannel セッションが必要になります。このメンバーの値を 0 に設定すると、既定値である 36000000 ミリ秒 (10 時間) が使用されます。 | ||||||||||||||||||||||||||||||||||||||||||||||||||
| dwFlags | SCHANNEL_CRED_FLAGS | 4 | +72 | +48 | Schannel の動作を制御するビットフラグを格納します。このメンバーには 0、または次の値の組み合わせを指定できます。
| ||||||||||||||||||||||||||||||||||||||||||||||||||
| dwCredFormat | DWORD | 4 | +76 | +52 | カーネルモードの Schannel は、次の値をサポートします。 Windows Server 2008, Windows Vista, Windows Server 2003, Windows XP and Windows XP/2000: このフラグはサポートされておらず、0 でなければなりません。
|
公式ドキュメント
SCHANNEL_CRED 構造体は非推奨です。代わりに SCH_CREDENTIALS を使用してください。
SCHANNEL_CRED 構造体は、Schannel 資格情報のデータを格納します。
解説(Remarks)
次の証明書失効フラグは相互に排他的です。
- SCH_CRED_REVOCATION_CHECK_CHAIN
- SCH_CRED_REVOCATION_CHECK_END_CERT
- SCH_CRED_REVOCATION_CHECK_CHAIN_EXCLUDE_ROOT
Schannel の証明書失効エラーの報告方法をカスタマイズするには、次のフラグを使用します。
Schannel が証明書チェーンの失効状態を確認する際、これらのフラグはそれぞれ CRYPT_E_NO_REVOCATION_CHECK エラーと CRYPT_E_REVOCATION_OFFLINE エラーを無視するよう指示します。証明書失効フラグが設定されていない場合、これらのフラグは無視されます。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での定義
#include <windows.h>
// SCHANNEL_CRED (x64 80 / x86 56 バイト)
typedef struct SCHANNEL_CRED {
DWORD dwVersion;
DWORD cCreds;
CERT_CONTEXT** paCred;
HCERTSTORE hRootStore;
DWORD cMappers;
_HMAPPER** aphMappers;
DWORD cSupportedAlgs;
ALG_ID* palgSupportedAlgs;
DWORD grbitEnabledProtocols;
DWORD dwMinimumCipherStrength;
DWORD dwMaximumCipherStrength;
DWORD dwSessionLifespan;
SCHANNEL_CRED_FLAGS dwFlags;
DWORD dwCredFormat;
} SCHANNEL_CRED;using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public struct SCHANNEL_CRED
{
public uint dwVersion;
public uint cCreds;
public IntPtr paCred;
public IntPtr hRootStore;
public uint cMappers;
public IntPtr aphMappers;
public uint cSupportedAlgs;
public IntPtr palgSupportedAlgs;
public uint grbitEnabledProtocols;
public uint dwMinimumCipherStrength;
public uint dwMaximumCipherStrength;
public uint dwSessionLifespan;
public uint dwFlags;
public uint dwCredFormat;
}Imports System.Runtime.InteropServices
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Structure SCHANNEL_CRED
Public dwVersion As UInteger
Public cCreds As UInteger
Public paCred As IntPtr
Public hRootStore As IntPtr
Public cMappers As UInteger
Public aphMappers As IntPtr
Public cSupportedAlgs As UInteger
Public palgSupportedAlgs As IntPtr
Public grbitEnabledProtocols As UInteger
Public dwMinimumCipherStrength As UInteger
Public dwMaximumCipherStrength As UInteger
Public dwSessionLifespan As UInteger
Public dwFlags As UInteger
Public dwCredFormat As UInteger
End Structureimport ctypes
from ctypes import wintypes
class SCHANNEL_CRED(ctypes.Structure):
_fields_ = [
("dwVersion", wintypes.DWORD),
("cCreds", wintypes.DWORD),
("paCred", ctypes.c_void_p),
("hRootStore", ctypes.c_void_p),
("cMappers", wintypes.DWORD),
("aphMappers", ctypes.c_void_p),
("cSupportedAlgs", wintypes.DWORD),
("palgSupportedAlgs", ctypes.c_void_p),
("grbitEnabledProtocols", wintypes.DWORD),
("dwMinimumCipherStrength", wintypes.DWORD),
("dwMaximumCipherStrength", wintypes.DWORD),
("dwSessionLifespan", wintypes.DWORD),
("dwFlags", wintypes.DWORD),
("dwCredFormat", wintypes.DWORD),
]#[repr(C)]
pub struct SCHANNEL_CRED {
pub dwVersion: u32,
pub cCreds: u32,
pub paCred: *mut core::ffi::c_void,
pub hRootStore: *mut core::ffi::c_void,
pub cMappers: u32,
pub aphMappers: *mut core::ffi::c_void,
pub cSupportedAlgs: u32,
pub palgSupportedAlgs: *mut core::ffi::c_void,
pub grbitEnabledProtocols: u32,
pub dwMinimumCipherStrength: u32,
pub dwMaximumCipherStrength: u32,
pub dwSessionLifespan: u32,
pub dwFlags: u32,
pub dwCredFormat: u32,
}import "golang.org/x/sys/windows"
type SCHANNEL_CRED struct {
dwVersion uint32
cCreds uint32
paCred uintptr
hRootStore uintptr
cMappers uint32
aphMappers uintptr
cSupportedAlgs uint32
palgSupportedAlgs uintptr
grbitEnabledProtocols uint32
dwMinimumCipherStrength uint32
dwMaximumCipherStrength uint32
dwSessionLifespan uint32
dwFlags uint32
dwCredFormat uint32
}type
SCHANNEL_CRED = record
dwVersion: DWORD;
cCreds: DWORD;
paCred: Pointer;
hRootStore: Pointer;
cMappers: DWORD;
aphMappers: Pointer;
cSupportedAlgs: DWORD;
palgSupportedAlgs: Pointer;
grbitEnabledProtocols: DWORD;
dwMinimumCipherStrength: DWORD;
dwMaximumCipherStrength: DWORD;
dwSessionLifespan: DWORD;
dwFlags: DWORD;
dwCredFormat: DWORD;
end;const SCHANNEL_CRED = extern struct {
dwVersion: u32,
cCreds: u32,
paCred: ?*anyopaque,
hRootStore: ?*anyopaque,
cMappers: u32,
aphMappers: ?*anyopaque,
cSupportedAlgs: u32,
palgSupportedAlgs: ?*anyopaque,
grbitEnabledProtocols: u32,
dwMinimumCipherStrength: u32,
dwMaximumCipherStrength: u32,
dwSessionLifespan: u32,
dwFlags: u32,
dwCredFormat: u32,
};type
SCHANNEL_CRED {.bycopy.} = object
dwVersion: uint32
cCreds: uint32
paCred: pointer
hRootStore: pointer
cMappers: uint32
aphMappers: pointer
cSupportedAlgs: uint32
palgSupportedAlgs: pointer
grbitEnabledProtocols: uint32
dwMinimumCipherStrength: uint32
dwMaximumCipherStrength: uint32
dwSessionLifespan: uint32
dwFlags: uint32
dwCredFormat: uint32struct SCHANNEL_CRED
{
uint dwVersion;
uint cCreds;
void* paCred;
void* hRootStore;
uint cMappers;
void* aphMappers;
uint cSupportedAlgs;
void* palgSupportedAlgs;
uint grbitEnabledProtocols;
uint dwMinimumCipherStrength;
uint dwMaximumCipherStrength;
uint dwSessionLifespan;
uint dwFlags;
uint dwCredFormat;
}HSP用 定義
HSP3.7/3.8 は構造体機能が無いため4byte整数配列(dim)+peek/poke で操作(32/64bitでサイズ・位置が異なる場合はタブで分割)。IronHSP は NSTRUCT(#defstruct/stdim/->)で32/64bit共通。
; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x86 レイアウト)
; SCHANNEL_CRED サイズ: 56 バイト(x86)
dim st, 14 ; 4byte整数×14(構造体サイズ 56 / 4 切り上げ)
; dwVersion : DWORD (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; cCreds : DWORD (+4, 4byte) st.1 = 値 / 値 = st.1 (lpoke/lpeek も可)
; paCred : CERT_CONTEXT** (+8, 4byte) varptr(st)+8 を基点に操作(4byte:入れ子/配列)
; hRootStore : HCERTSTORE (+12, 4byte) st.3 = 値 / 値 = st.3 (lpoke/lpeek も可)
; cMappers : DWORD (+16, 4byte) st.4 = 値 / 値 = st.4 (lpoke/lpeek も可)
; aphMappers : _HMAPPER** (+20, 4byte) st.5 = 値 / 値 = st.5 (lpoke/lpeek も可)
; cSupportedAlgs : DWORD (+24, 4byte) st.6 = 値 / 値 = st.6 (lpoke/lpeek も可)
; palgSupportedAlgs : ALG_ID* (+28, 4byte) st.7 = 値 / 値 = st.7 (lpoke/lpeek も可)
; grbitEnabledProtocols : DWORD (+32, 4byte) st.8 = 値 / 値 = st.8 (lpoke/lpeek も可)
; dwMinimumCipherStrength : DWORD (+36, 4byte) st.9 = 値 / 値 = st.9 (lpoke/lpeek も可)
; dwMaximumCipherStrength : DWORD (+40, 4byte) st.10 = 値 / 値 = st.10 (lpoke/lpeek も可)
; dwSessionLifespan : DWORD (+44, 4byte) st.11 = 値 / 値 = st.11 (lpoke/lpeek も可)
; dwFlags : SCHANNEL_CRED_FLAGS (+48, 4byte) st.12 = 値 / 値 = st.12 (lpoke/lpeek も可)
; dwCredFormat : DWORD (+52, 4byte) st.13 = 値 / 値 = st.13 (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; HSP3.7/3.8 は構造体機能が無いため、4byte整数の配列変数で操作します。(x64 レイアウト)
; SCHANNEL_CRED サイズ: 80 バイト(x64)
dim st, 20 ; 4byte整数×20(構造体サイズ 80 / 4 切り上げ)
; dwVersion : DWORD (+0, 4byte) st.0 = 値 / 値 = st.0 (lpoke/lpeek も可)
; cCreds : DWORD (+4, 4byte) st.1 = 値 / 値 = st.1 (lpoke/lpeek も可)
; paCred : CERT_CONTEXT** (+8, 8byte) varptr(st)+8 を基点に操作(8byte:入れ子/配列)
; hRootStore : HCERTSTORE (+16, 8byte) qpoke st,16,値 / qpeek(st,16) ※IronHSPのみ。3.7/3.8は lpoke st,16,下位 : lpoke st,20,上位
; cMappers : DWORD (+24, 4byte) st.6 = 値 / 値 = st.6 (lpoke/lpeek も可)
; aphMappers : _HMAPPER** (+32, 8byte) qpoke st,32,値 / qpeek(st,32) ※IronHSPのみ。3.7/3.8は lpoke st,32,下位 : lpoke st,36,上位
; cSupportedAlgs : DWORD (+40, 4byte) st.10 = 値 / 値 = st.10 (lpoke/lpeek も可)
; palgSupportedAlgs : ALG_ID* (+48, 8byte) qpoke st,48,値 / qpeek(st,48) ※IronHSPのみ。3.7/3.8は lpoke st,48,下位 : lpoke st,52,上位
; grbitEnabledProtocols : DWORD (+56, 4byte) st.14 = 値 / 値 = st.14 (lpoke/lpeek も可)
; dwMinimumCipherStrength : DWORD (+60, 4byte) st.15 = 値 / 値 = st.15 (lpoke/lpeek も可)
; dwMaximumCipherStrength : DWORD (+64, 4byte) st.16 = 値 / 値 = st.16 (lpoke/lpeek も可)
; dwSessionLifespan : DWORD (+68, 4byte) st.17 = 値 / 値 = st.17 (lpoke/lpeek も可)
; dwFlags : SCHANNEL_CRED_FLAGS (+72, 4byte) st.18 = 値 / 値 = st.18 (lpoke/lpeek も可)
; dwCredFormat : DWORD (+76, 4byte) st.19 = 値 / 値 = st.19 (lpoke/lpeek も可)
; ※4byte境界の整数は添字 st.N(N=オフセット/4)で読み書き可。それ以外は peek/poke 系を使用。; IronHSP は NSTRUCT(構造体)をサポート。32bit/64bit どちらでも同じコードで動作します。
#defstruct global SCHANNEL_CRED
#field int dwVersion
#field int cCreds
#field intptr paCred
#field intptr hRootStore
#field int cMappers
#field intptr aphMappers
#field int cSupportedAlgs
#field intptr palgSupportedAlgs
#field int grbitEnabledProtocols
#field int dwMinimumCipherStrength
#field int dwMaximumCipherStrength
#field int dwSessionLifespan
#field int dwFlags
#field int dwCredFormat
#endstruct
stdim st, SCHANNEL_CRED ; NSTRUCT 変数を確保
st->dwVersion = 100
mes "dwVersion=" + st->dwVersion