Digital signature uses asymmetric encryption technology. Everyone has a pair of keys, the private key is only known to himself, the public key is public, the private key is signed and the public key is verified.
When transmitting information, the information sender generates a signature with the private key and sends it to the information receiver together with the public key, and the receiver verifies the signature with the public key. In the above process, the integrity of the information is verified, but it is impossible to know whether the sender's identity is legal (because anyone can claim to be legal), so identity authentication institutions are introduced.
The authentication institution is an institution that the information receiver can trust, and all public keys must be registered with this institution. After registration, the authentication institution issues a digital certificate to the sender. After signing the document, the sender sends the digital certificate together with the document and signature to the information receiver, and the receiver verifies whether the document is really signed with the sender's key.
A digital certificate is an electronic file used to prove the identity of the owner of a public key. The file contains public key information, owner's identity information (subject) and digital signature of the file by the digital certificate authority (issuer).
The essence of certificate is to digitally sign the public key, and the certification authority digitally signs the public key of the person (or organization) who needs to be authenticated with its own private key to generate the certificate.
We need to know the following types of certificates.
Self-service visa
Users can generate their own digital certificates, but these certificates are not signed by anyone who can be trusted. They are mainly used for small-scale testing. This kind of self-signed certificate is usually not widely trusted, and you may encounter security warnings from computer software when using it.
Root certificate
Root certificates are widely recognized and usually pre-installed in various software (including operating system, browser, email software, etc. As the starting point of the trust chain, the root certificate comes from recognized and reliable government agencies, certificate issuing companies, non-profit organizations, etc. , and widely deployed in different softwares of major software vendors through strict verification procedures. Because the deployment procedure is complex and time-consuming, it needs the authorization of administrative personnel and the verification of the legal person identity of the institution. The root certificate may be valid for more than 20 years. In some enterprises, the root certificate signed by the enterprise may also be installed on the internal computer to support the enterprise-level software of the intranet; However, these certificates may not be widely recognized and only apply to enterprises.
Intermediary certificate
An important task of certification bodies is to issue certificates to customers. Although a widely recognized certification authority already has a root certificate, the corresponding private key can be used to sign other certificates. However, for the sake of key management and administration, the intermediary certificate is usually issued before the digital signature for the customer. The validity period of the intermediary certificate will be shorter than that of the root certificate, and different types of customers may have different intermediary certificates.
TLS server certificate
When a website provides services on the Internet, the domain name is the main body of the server certificate, and the name of the relevant institution is written in the column of institution or unit. The certificate and private key will be installed on the server. The client software (such as browser) will implement an authentication path verification algorithm to ensure security. If you are not sure whether the encryption channel is secure (for example, the subject name on the certificate does not correspond to the domain name of the website, the server uses a self-signed certificate, or the encryption algorithm is not strong enough), users may be warned.
TLS client certificate
The client certificate contains an e-mail address or personal name, not a host name. Client certificates are not common, because considering the technical threshold and cost factors, service providers usually verify the identity of customers instead of relying on third-party certification bodies. Usually, the services that need to use the client certificate are enterprise-level software in the intranet. They will establish their own internal root certificates, and the technicians of the enterprise will install the relevant client certificates on the computers in the enterprise for use. In the open Internet, most websites use login passwords and Cookie to authenticate users instead of client certificates.
Root certificate (self-signed certificate), intermediate certificate and terminal entity (TLS server/client) certificate form the following trust chain.
Certificates usually follow the X.509 format specification.
Certificates can be stored in binary or Base64 format. Common file extensions are. cer,。 crt,。 Der and. pem。 If the certificate and private key are stored together, you can use PKCS# 12(.p 12) format.
When we wrote the external API, we designed the security of information transmission as follows.
We use SHA256withRSA for signature. Here is a simple Java example.