重庆分公司,新征程启航

为企业提供网站建设、域名注册、服务器等服务

SSL的认证原理及使用openssl创建CA自认证证书-创新互联

如何制作自认证证书

成都网站建设哪家好,找创新互联建站!专注于网页设计、重庆网站建设公司、微信开发、微信小程序、集团成都企业网站建设等服务项目。核心团队均拥有互联网行业多年经验,服务众多知名企业客户;涵盖的客户类型包括:成都地磅秤等众多领域,积累了大量丰富的经验,同时也获得了客户的一致夸奖!

通用网络间的安全传输离不开SSL,SSL代表着[公开密钥加密(PKI)]技术的应用

简单来讲,使用公开密钥加密,每单次传输过程需要两个密钥完成,即加密密钥和解秘密钥

数据的提供方,即数据传输的出发点对数据进行加密,之后传输,加密使用的密钥是公开的,称为公钥(public key)

数据的接收方,对接收到的数据进行解密处理,密钥不公开,称为私钥(private key)

SSL中公钥和私钥配对使用,即1个公钥对应1个私钥(其他模型/算法也可以实现1对多,多对多的密钥匹配),由数据的接收方计算,并将公钥通知对方

所以,实际应用中,完成一次数据交互,单方向可读可写,则需要两个密钥对,传输方各持一个公钥,一个私钥

在开始传输之前,建立连接过程中,公钥可以用明文传输(SSL的握手协议)

只要私钥复杂到难以破解,传输的既可以保持安全性,又可以保持随意性,即无需事先交换,利用现有网络,即使有监听,只要保证私钥保密,就可以实现数据的安全传输

但是,问题在于,如果在恶意监听过程中,公钥在传输给另一方时被替换,相当于监听者与传输的双方建立两个假安全连接,获取传输的内容。

为解决这个问题,SSL的解决方案中使用了对数据提供方的认证机制

数据的接收方预先保留一些认证机构(CA)的信息,数据服务方需要到认证机构对自己的公钥作认证处理,接收方使用CA的信息和数据服务方的认证信息解析验证服务方公钥的有效性

CA被视为整个流程中的源头,CA可以是权威的认证机构,当然也可以自行定制生成,目的仅是保证SSL机制的顺利执行

在整个机制中,数据接收方(客户端)所需的信息

CA.crt

Server.crt

Server.public_key

都可以由openssl命令执行生成

openssl genrsa -des3 -out ca.key 1024

openssl req -new -key ca.key -out ca.csr

cp ca.key ca.key.org
openssl rsa -in ca.key.org -out ca.key

openssl x509 -req -days 365 -in ca.csr -signkey ca.key -out ca.crt

使用相同的方法生成server.key

用ca信息对其作认证处理

openssl x509 -req -days 3650 -in server.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out server.crt

附加计算工具参数

openssl dHParam -outform PEM -out dh2024.pem 1024

参考文章

http://www.akadia.com/services/ssh_test_certificate.html

Zurück
How to create a self-signed SSL Certificate ...

... which can be used for testing purposes or internal usage

Overview

   The following is an extremely simplified view of how SSL is implemented and what part the certificate plays in the entire process.

   Normal web traffic is sent unencrypted over the Internet. That is, anyone with access to the right tools can snoop all of that traffic. Obviously, this can lead to problems, especially where security and privacy is necessary, such as in credit card data and bank transactions. The Secure Socket Layer is used to encrypt the data stream between the web server and the web client (the browser).

   SSL makes use of what is known as asymmetric cryptography, commonly referred to as public key cryptography (PKI). With public key cryptography, two keys are created, one public, one private. Anything encrypted with either key can only be decrypted with its corresponding key. Thus if a message or data stream were encrypted with the server's private key, it can be decrypted only using its corresponding public key, ensuring that the data only could have come from the server.

   If SSL utilizes public key cryptography to encrypt the data stream traveling over the Internet, why is a certificate necessary? The technical answer to that question is that a certificate is not really necessary - the data is secure and cannot easily be decrypted by a third party. However, certificates do serve a crucial role in the communication process. The certificate, signed by a trusted Certificate Authority (CA), ensures that the certificate holder is really who he claims to be. Without a trusted signed certificate, your data may be encrypted, however, the party you are communicating with may not be whom you think. Without certificates, impersonation attacks would be much more common.

Step 1: Generate a Private Key

   The openssl toolkit is used to generate an RSA Private Key and CSR (Certificate Signing Request). It can also be used to generate self-signed certificates which can be used for testing purposes or internal usage.

   The first step is to create your RSA Private Key. This key is a 1024 bit RSA key which is encrypted using Triple-DES and stored in a PEM format so that it is readable as ASCII text.

   openssl genrsa -des3 -out server.key 1024
Generating RSA private key, 1024 bit long modulus
.........................................................++++++
........++++++
   e is 65537 (0x10001)
Enter PEM pass phrase:
Verifying password - Enter PEM pass phrase:

Step 2: Generate a CSR (Certificate Signing Request)

   Once the private key is generated a Certificate Signing Request can be generated. The CSR is then used in one of two ways. Ideally, the CSR will be sent to a Certificate Authority, such as Thawte or Verisign who will verify the identity of the requestor and issue a signed certificate. The second option is to self-sign the CSR, which will be demonstrated in the next section.

   During the generation of the CSR, you will be prompted for several pieces of information. These are the X.509 attributes of the certificate. One of the prompts will be for "Common Name (e.g., YOUR name)". It is important that this field be filled in with the fully qualified domain name of the server to be protected by SSL. If the website to be protected will be https://public.akadia.com, then enter public.akadia.com at this prompt. The command to generate the CSR is as follows:

   openssl req -new -key server.key -out server.csr

   Country Name (2 letter code) [GB]:CH
   State or Province Name (full name) [Berkshire]:Bern
   Locality Name (eg, city) [Newbury]:Oberdiessbach
   Organization Name (eg, company) [My Company Ltd]:Akadia AG
   Organizational Unit Name (eg, section) []:Information Technology
   Common Name (eg, your name or your server's hostname) []:public.akadia.com
   Email Address []:martin dot zahn at akadia dot ch
   Please enter the following 'extra' attributes
   to be sent with your certificate request
   A challenge password []:
   An optional company name []:

Step 3: Remove Passphrase from Key

   One unfortunate side-effect of the pass-phrased private key is that Apache will ask for the pass-phrase each time the web server is started. Obviously this is not necessarily convenient as someone will not always be around to type in the pass-phrase, such as after a reboot or crash. mod_ssl includes the ability to use an external program in place of the built-in pass-phrase dialog, however, this is not necessarily the most secure option either. It is possible to remove the Triple-DES encryption from the key, thereby no longer needing to type in a pass-phrase. If the private key is no longer encrypted, it is critical that this file only be readable by the root user! If your system is ever compromised and a third party obtains your unencrypted private key, the corresponding certificate will need to be revoked. With that being said, use the following command to remove the pass-phrase from the key:

   cp server.key server.key.org
   openssl rsa -in server.key.org -out server.key

The newly created server.key file has no more passphrase in it.

   -rw-r--r-- 1 root root 745 Jun 29 12:19 server.csr
   -rw-r--r-- 1 root root 891 Jun 29 13:22 server.key
   -rw-r--r-- 1 root root 963 Jun 29 13:22 server.key.org

Step 4: Generating a Self-Signed Certificate

   At this point you will need to generate a self-signed certificate because you either don't plan on having your certificate signed by a CA, or you wish to test your new SSL implementation while the CA is signing your certificate. This temporary certificate will generate an error in the client browser to the effect that the signing certificate authority is unknown and not trusted.

   To generate a temporary certificate which is good for 365 days, issue the following command:

   openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
   Signature ok
   subject=/C=CH/ST=Bern/L=Oberdiessbach/O=Akadia AG/OU=Information
   Technology/CN=public.akadia.com/Email=martin dot zahn at akadia dot ch
   Getting Private key

   通过CA文件认证服务器文件

   openssl x509 -req -days 3650 -in server.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out server.crt

   dh文件生成
   openssl dHParam -outform PEM -out dh2024.pem 1024

另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


网站标题:SSL的认证原理及使用openssl创建CA自认证证书-创新互联
本文网址:http://cqcxhl.cn/article/dgeioh.html

其他资讯

在线咨询
服务热线
服务热线:028-86922220
TOP