What is the difference between M2Crypto's set_client_CA_list_from_file() and load_verify_info() and when would you use each?

非 Y 不嫁゛ 提交于 2020-01-05 03:10:46

问题


The M2Crypto library has a few CA-related functions on its SSL.Context object, but the documentation is very unclear as to when you would use certain functions and why. In fact, the docs for almost all of them are, "Load CA certs into the context," so it seems possible that they all do the same thing.

There are several examples that use both set_client_CA_list_from_file() and load_verify_info(), but there are also other similar functions like load_client_ca() and load_verify_locations().

I am writing both client and server pieces. What functions should I use and why? What specifically do they do?

Edit:

Looking through the code I see:

# Deprecated.
load_client_CA = load_client_ca = set_client_CA_list_from_file

and

# Deprecated.
load_verify_info = load_verify_locations

So that helps a little. This brings us down to two functions: set_client_CA_list_from_file() and load_verify_locations(). But I still can't quite tell the difference between the two.


回答1:


If your server requires the client to present a certificate, it can restrict who are the valid issuers of the client certificates by specifying the issuers calling set_client_CA_list_from_file. This is actually pretty rare.

The client specifies who are the valid server certificate issuers by calling load_verify_locations. Almost all clients should do this.

Both client and server can call load_cert to set their own certificate. Servers should almost always do this. Clients should probably do this only if the server requires the client to present a certificate.

I recommend you pick a copy of Network Security with OpenSSL by John Viega, Matt Messier and Pravir Chandra, ISBN 059600270X, which should clarify these issues in more detail.



来源:https://stackoverflow.com/questions/1848160/what-is-the-difference-between-m2cryptos-set-client-ca-list-from-file-and-loa

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!