检查windows系统支持的密码套件
2021-05-02 15:28
标签:删除 src out ros local library mars log 代码 Windows 10客户端及Windows server 2016 服务器可以使用powershell 命令获得系统支持的密码套件列表,禁用启用相应的密码套件。 Windows server 2016之前版本微软并没有给出相应的powershell 命令来获取密码套件列表,但在msdn上给出了c++代码 msdn链接:https://msdn.microsoft.com/en-us/library/windows/desktop/bb870930(v=vs.85).aspx stackoverflow.上有人将获得密码套件列表的代码改成了c#,然后利用powershell 命令可以直接调用这些代码(add-type),也可以将这些代码利用csc.exe编译成.dll或者.exe,建议编译成exe,可以直接在其他的终端cmd控制台调用。 stackoverflow.链接:https://stackoverflow.com/questions/19695623/how-to-call-schannel-functions-from-net-c openssl 也可以获得密码套件列表: 微软也给出了各操作系统版本中默认启用的密码套件列表以及相应的设置 各操作系统支持密码套件的列表:https://msdn.microsoft.com/en-us/library/windows/desktop/aa374757%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396 TLS/SSL设置:https://technet.microsoft.com/zh-cn/library/dn786418%28v=ws.11%29.aspx?f=255&MSPPError=-2147217396#BKMK_SchannelTR_SSL30 检查windows系统支持的密码套件 标签:删除 src out ros local library mars log 代码 原文地址:http://www.cnblogs.com/-windows/p/7765439.html#命令链接:https://technet.microsoft.com/zh-cn/library/dn931990.aspx
#win10 server2016获得系统支持的套件的列表
Get-TlsCipherSuite |ft name
#win10 server2016启用密码套件
Enable-TlsCipherSuite -name ""
#win10 server2016禁用密码套件
Disable-TlsCipherSuite -name "" 1 #include
1 #include
1 #include
1 using System;
2 using System.Text;
3 using System.Runtime.InteropServices;
4
5 namespace ConsoleApplication1
6 {
7 class Program
8 {
9 [DllImport("Bcrypt.dll", CharSet = CharSet.Unicode)]
10 static extern uint BCryptEnumContextFunctions(uint dwTable, string pszContext, uint dwInterface, ref uint pcbBuffer, ref IntPtr ppBuffer);
11
12 [DllImport("Bcrypt.dll")]
13 static extern void BCryptFreeBuffer(IntPtr pvBuffer);
14
15 [DllImport("Bcrypt.dll", CharSet = CharSet.Unicode)]
16 static extern uint BCryptAddContextFunction(uint dwTable, string pszContext, uint dwInterface, string pszFunction, uint dwPosition);
17
18 [DllImport("Bcrypt.dll", CharSet = CharSet.Unicode)]
19 static extern uint BCryptRemoveContextFunction(uint dwTable, string pszContext, uint dwInterface, string pszFunction);
20
21 [StructLayout(LayoutKind.Sequential)]
22 public struct CRYPT_CONTEXT_FUNCTIONS
23 {
24 public uint cFunctions;
25 public IntPtr rgpszFunctions;
26 }
27
28 const uint CRYPT_LOCAL = 0x00000001;
29 const uint NCRYPT_SCHANNEL_INTERFACE = 0x00010002;
30 const uint CRYPT_PRIORITY_TOP = 0x00000000;
31 const uint CRYPT_PRIORITY_BOTTOM = 0xFFFFFFFF;
32
33 public static void DoStuff()
34 {
35 uint cbBuffer = 0;
36 IntPtr ppBuffer = IntPtr.Zero;
37 uint Status = BCryptEnumContextFunctions(
38 CRYPT_LOCAL,
39 "SSL",
40 NCRYPT_SCHANNEL_INTERFACE,
41 ref cbBuffer,
42 ref ppBuffer);
43 if (Status == 0)
44 {
45 CRYPT_CONTEXT_FUNCTIONS functions = (CRYPT_CONTEXT_FUNCTIONS)Marshal.PtrToStructure(ppBuffer, typeof(CRYPT_CONTEXT_FUNCTIONS));
46 Console.WriteLine(functions.cFunctions);
47 IntPtr pStr = functions.rgpszFunctions;
48 for (int i = 0; i )
49 {
50 Console.WriteLine(Marshal.PtrToStringUni(Marshal.ReadIntPtr(pStr)));
51 pStr += IntPtr.Size;
52 }
53 BCryptFreeBuffer(ppBuffer);
54 }
55 }
56
57 static void Main(string[] args)
58 {
59 DoStuff();
60 Console.ReadLine();
61 }
62 }
63 }
opessl ciphers -v
上一篇:C# 字符串,时间,数学类型
文章标题:检查windows系统支持的密码套件
文章链接:http://soscw.com/index.php/essay/81391.html