简体   繁体   English

如何为x509证书指定TLS版本

[英]How to specifiy the TLS version for an x509 Certificate

I am developing an application that communicates with a server through a secure communication. 我正在开发一个通过安全通信与服务器通信的应用程序。 So the user of the application should choose a client certificate file (x509 certificate) i want to add the possibility for the user to specify the TLS version. 因此,应用程序的用户应选择一个客户端证书文件(x509证书),我想为用户添加指定TLS版本的可能性。 I didn't find any attribute in the instance of x509Certificate cert = new X509Certificate(FileName) that identifies the TLS version. 在x509Certificate cert = new X509Certificate(FileName)的实例中找不到标识TLS版本的任何属性。 How to proceed ? 如何进行 ?

Version of TLS and version of X509 certificate are totally different two things. TLS版本和X509证书版本是完全不同的两件事。 If you're referring TLS version, it can be specified with various versions of client/server methods of openssl library (can be set to SSL_CTX or SSL): 如果您指的是TLS版本,则可以使用openssl库的客户端/服务器方法的各种版本来指定它(可以设置为SSL_CTX或SSL):

const SSL_METHOD *SSLv23_method(void);
const SSL_METHOD *TLSv1_2_method(void);
const SSL_METHOD *TLSv1_1_method(void);
const SSL_METHOD *TLSv1_method(void);
const SSL_METHOD *SSLv3_method(void);
const SSL_METHOD *SSLv2_method(void);

But if you really mean version of X509 this can be defined using openssl library functions. 但是,如果您真的是X509版本,则可以使用openssl库函数来定义。 X509 struct holds a certificate info struct which is defined as (1.0.2l) below: X509结构包含以下定义为(1.0.2l)的证书信息结构:

typedef struct x509_cinf_st {
    ASN1_INTEGER *version;      /* [ 0 ] default of v1 */
    ASN1_INTEGER *serialNumber;
    X509_ALGOR *signature;
    X509_NAME *issuer;
    X509_VAL *validity;
    X509_NAME *subject;
    X509_PUBKEY *key;
    ASN1_BIT_STRING *issuerUID; /* [ 1 ] optional in v2 */
    ASN1_BIT_STRING *subjectUID; /* [ 2 ] optional in v2 */
    STACK_OF(X509_EXTENSION) *extensions; /* [ 3 ] optional in v3 */
    ASN1_ENCODING enc;
} X509_CINF;

And you will most probably using functions below to handle version: 您很可能会使用下面的函数来处理版本:

X509_CINF_new(void); 
X509_CINF * d2i_X509_CINF(X509_CINF **val_out, const unsigned char **der_in, long length);
int i2d_X509_CINF(X509_CINF *val_in, unsigned char **der_out); 

But since v2 and v3 hold optional fields, there is no reason not to have v3. 但是由于v2和v3包含可选字段,因此没有理由不使用v3。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM