SSL认证链不适用于自签名证书(SSL chain of certification not working for a self signed certificate)
客户给了我们3个证书,这些证书按顺序安装在Windows服务器上,并且:
- 由Verisign发布,适用于Symantec(仅限证书,作为中间件安装)
- Symantec发布,适用于CompanyX(仅限证书,安装为中间版)
- CompanyX发布,适用于CompanyX(证书和密钥,安装为个人)
在mmc中,当我检查#2时,我可以看到链为:
Verisign(root) - > Verisign(中间) - > Symantec(中级)
检查#3(自签名证书)时,没有链。 只有CompanyX。
似乎Windows无法在最后一个中间证书和自签名证书之间建立链,因此当客户端连接到Web服务器时,他们会看到自签名或不受信任的证书警告,可能是因为服务器未发布中间证书。
我已经验证了通用名称是否完全匹配,并重复了几次安装程序。 我在安装证书时做错了吗? 我错过了什么吗?
A customer has given us 3 certificates, which were installed on a windows server in the order and :
- Issued by Verisign, for Symantec (certificate only, installed as intermediate)
- Issued by Symantec, for CompanyX (certificate only, installed as intermediate)
- Issued by CompanyX, for CompanyX (certificate and key, installed as Personal)
In mmc, when I inspect #2, I can see the chain as:
Verisign (root) -> Verisign (intermediate) --> Symantec (intermediate)
When inspecting #3 (the self signed certificate), there is no chain. There's only CompanyX.
Seems like windows is failing to establish the chain between the last intermediate and the self signed certificate, so when clients connect to the web server, they see a self-signed or untrusted certificate warning, presumably because the server is not publishing the intermediate certificates.
I've already verified that common names match exactly, and repeated the installation procedures a few times. Did I do something wrong installing the certificates? Am I missing something?
原文:https://stackoverflow.com/questions/36629306
最满意答案
你需要使用反射。
MakeGenericType
允许您使用特定的泛型参数获取Type
,然后您可以根据需要获取并调用任何方法。void Main() { Type t = typeof(int); Type at = typeof(A<>).MakeGenericType(t); at.GetMethod("B").Invoke(null, new object[]{"test"}); } public class A<T> { public static void B(string s) { Console.WriteLine(s+" "+typeof(T).Name); } }
作为性能优化,您可以使用反射来获取每种类型的委托,然后您可以调用它而无需进一步反映。
Type t = typeof(int); Type at = typeof(A<>).MakeGenericType(t); Action<string> action = (Action<string>)Delegate.CreateDelegate(typeof(Action<string>), at.GetMethod("B")); action("test");
You need to use reflection.
MakeGenericType
allows you to get theType
with specific generic arguments and then you can get and call any method on it as you like.void Main() { Type t = typeof(int); Type at = typeof(A<>).MakeGenericType(t); at.GetMethod("B").Invoke(null, new object[]{"test"}); } public class A<T> { public static void B(string s) { Console.WriteLine(s+" "+typeof(T).Name); } }
As a performance optimization you could use reflection to get a delegate for each type which you then can invoke without further reflection.
Type t = typeof(int); Type at = typeof(A<>).MakeGenericType(t); Action<string> action = (Action<string>)Delegate.CreateDelegate(typeof(Action<string>), at.GetMethod("B")); action("test");
相关问答
更多-
TCP/IP模型是一个________。[2023-05-19]
a -
下列中不属于面向对象的编程语言的是?[2022-05-30]
a -
在这种情况下,您应该直接在约束类型上调用静态方法。 C#(和CLR)不支持虚拟静态方法。 所以T.StaticMethodOnSomeBaseClassThatReturnsCollection可以和SomeBaseClass.StaticMethodOnSomeBaseClassThatReturnsCollection无关。 遍历泛型类型参数是不必要的间接,因此不受支持。 In this case you should just call the static method on the constra ...
-
调用一个静态方法,因为它的动态类型和参数在c#(Call a static method given it's dynamic type and arguments in c#)[2022-09-24]
您正在寻找MethodInfo的MakeGenericMethod方法: Type.GetType("MyClass") .GetMethod("MyMethod") .MakeGenericMethod(typeOfGenericArgument) .Invoke(null, new object[] { "student" }) You're looking for the MakeGenericMethod method of MethodInfo: Type.GetType ... -
在运行时确定的泛型类型上调用非泛型方法c#(calling nongeneric method on generic type determined at runtime c#)[2023-11-11]
从代码的格式中不完全清楚,但我认为这是你的问题: MethodDelegate是一个私有接口MessageMethods中的委托。 您应该公开您的接口,并在generic_method中使用以下语法: private static T generic_method(byte[] pinned_memory, ref int offset) where T : MessageMethods { MessageMethods.MethodDelegate m = new MessageMethod ... -
你需要使用反射。 MakeGenericType允许您使用特定的泛型参数获取Type ,然后您可以根据需要获取并调用任何方法。 void Main() { Type t = typeof(int); Type at = typeof(A<>).MakeGenericType(t); at.GetMethod("B").Invoke(null, new object[]{"test"}); } public class A
{ public static void B( ... -
您将需要方法Type.MakeGenericType ; 用法如下: var columnType = typeof(ColumnAttributeTypeMapper<>); var genericColumn = columnType.MakeGenericType(new[] {typeof(mappedType)}); var instance = Activator.CreateInstance(genericColumn); 我写这篇文章的时候没有intellisense,只是浏览了你的代码, ...
-
C#键入Generic类(C# Type to Generic class)[2022-02-26]
反思例子: public static void Main(string[] args) { Type t = typeof(string); Type fooType = typeof(Foo<>); Type genericFooType = fooType.MakeGenericType(t); object o = Activator.CreateInstance(genericFooType,null); MethodInfo method = generi ... -
当您执行Program1 : Program ,您告诉所有Program1实例不仅是Program1类型,而且还是Program类型,因为它继承了它。 但是当你执行Program1
,你会告诉Program1除了它自己的类型之外还可以有任何独立的类型参数,以便用这种独立的类型做事。 如果您使用Program1 : Program ,您的静态方法可以执行以下操作: class Program1 : Program { public static void check() { ... -
你被允许有一个非同名的非泛型类......也许类似于: abstract class DataAccessBase
: IDataAccess where T : AnotherAbstractClass { ... } static class DataAccessBase { public static IDataAccess CreateInstance(TypeToCreateEnum) {...} } 现在,您可以使用DataAccessBase.CreateInstanc ...