https 例子

双向认证 SSL 协议的具体过程
  ① 浏览器发送一个连接请求给安全服务器。
  ② 服务器将自己的证书,以及同证书相关的信息发送给客户浏览器。
  ③ 客户浏览器检查服务器送过来的证书是否是由自己信赖的 CA 中心所签发的。如果是,就继续执行协议;如果不是,客户浏览器就给客户一个警告消息:警告客户这个证书不是可以信赖的,询问客户是否需要继续。
  ④ 接着客户浏览器比较证书里的消息,例如域名和公钥,与服务器刚刚发送的相关消息是否一致,如果是一致的,客户浏览器认可这个服务器的合法身份。
  ⑤ 服务器要求客户发送客户自己的证书。收到后,服务器验证客户的证书,如果没有通过验证,拒绝连接;如果通过验证,服务器获得用户的公钥。
  ⑥ 客户浏览器告诉服务器自己所能够支持的通讯对称密码方案。
  ⑦ 服务器从客户发送过来的密码方案中,选择一种加密程度最高的密码方案,用客户的公钥加过密后通知浏览器。
  ⑧ 浏览器针对这个密码方案,选择一个通话密钥,接着用服务器的公钥加过密后发送给服务器。
  ⑨ 服务器接收到浏览器送过来的消息,用自己的私钥解密,获得通话密钥。
  ⑩ 服务器、浏览器接下来的通讯都是用对称密码方案,对称密钥是加过密的。


------------------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------------------------
证书各部分的含义
  <FONT face=宋体>Version 证书版本号,不同版本的证书格式不同
  Serial Number 序列号,同一身份验证机构签发的证书序列号唯一
  Algorithm Identifier 签名算法,包括必要的参数 Issuer 身份验证机构的标识信息
  Period of Validity 有效期
  Subject 证书持有人的标识信息
  Subject’s Public Key 证书持有人的公钥
  Signature 身份验证机构对证书的签名</FONT>
  证书的格式 认证中心所发放的证书均遵循 X.509 V3 标准,其基本格式如下:
  证书版本号(Certificate Format Version)
    含义:用来指定证书格式采用的 X.509 版本号。
  证书序列号(Certificate Serial Number)
    含义:用来指定证书的唯一序列号,以标识 CA 发出的所有公钥证书。
  签名(Signature) 算法标识(Algorithm Identifier)
    含义:用来指定 CA 签发证书所用的签名算法。
  签发此证书的 CA 名称(Issuer )
    含义:用来指定签发证书的 CA 的 X.500 唯一名称(DN, Distinguished Name)。
  证书有效期(Validity Period) 起始日期(notBefore) 终止日期(notAfter)
    含义:用来指定证书起始日期和终止日期。
  用户名称(Subject)
    含义:用来指定证书用户的 X.500 唯一名称(DN,Distinguished Name)。
  用户公钥信息(Subject Public Key Information) 算法(algorithm)算法标识(Algorithm Identifier) 用户公钥(subject Public Key)
    含义:用来标识公钥使用的算法,并包含公钥本身。
  证书扩充部分(扩展域)(Extensions)
    含义:用来指定额外信息。 
  X.509 V3 证书的扩充部分(扩展域)及实现方法如下:
  CA 的公钥标识(Authority Key Identifier)
  公钥标识(SET 未使用)(Key Identifier)
  签发证书者证书的签发者的甄别名(Certificate Issuer)
  签发证书者证书的序列号(Certificate Serial Number)
  X.509 V3 证书的扩充部分(扩展域)及实现CA 的公钥标识(Authority Key Identifier)
  公钥标识(SET 未使用)(Key Identifier)
  签发证书者证书的签发者的甄别名(Certificat签发证书者证书的序列号(Certificate Serial Number)
    含义:CA 签名证书所用的密钥对的唯一标识用户的公钥标识(Subject Key Identifier) 
    含义:用来标识与证书中公钥相关的特定密钥进行解密。
  证书中的公钥用途(Key Usage)
    含义:用来指定公钥用途。
  用户的私钥有效期(Private Key Usage Period) 起始日期(Note Before)终止日期(Note After)
    含义:用来指定用户签名私钥的起始日期和终止日期。
  CA 承认的证书政策列表(Certificate Policies)
    含义:用来指定用户证书所适用的政策,证书政策可由对象标识符表示。
  用户的代用名(Substitutional Name)
    含义:用来指定用户的代用名。
  CA 的代用名(Issuer Alt Name)
    含义:用来指定 CA 的代用名。
  基本制约(Basic Constraints)
    含义:用来表明证书用户是最终用户还是 CA。 在 SET 系统中有一些私有扩充部分(扩展域)Hashed Root Key 含义:只在根证书中使用,用于证书更新时进行回溯。
  证书类型(Certificate Type)
    含义:用来区别不同的实体。该项是必选的。
  商户数据(Merchant Data)
    含义:包含支付网关需要的所有商户信息。
  持卡人证书需求(Card Cert Required)
    含义:显示支付网关是否支持与没有证书的持卡人进行交易。
  SET 扩展(SETExtensions)
    含义:列出支付网关支持的支付命令的 SET 信息扩展。
  CRL 数据定义版本(Version)
    含义:显示 CRL 的版本号。
  CRL 的签发者(Issuer)
    含义:指明签发 CRL 的 CA 的甄别名。
  CRL 发布时间(this Update) 预计下一个 CRL 更新时间(Next Update)撤销证书信息目录(Revoked Certificates) CRL 扩展(CRL Extension) CA 的公钥标识(Authority Key Identifier) CRL 号(CRL Number)




------------------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------------------------
前几天客户提出要强制使用HTTPS方式访问Tomcat中的相关项目,于是研究了下,现将具体的步骤写下:
    主要分2步:让tomcat能使用https--->强制使用https访问
1.让tomcat能使用https
  A.在运行命令JAVA_HOME/bin/keytool -genkey -alias tomcat -keyalg 
    RSA  -keystore     C:\Tomcat\GMAE3.0Tomcat\tomcat.keystore
    这样就生成了证书,将证书放到合适的地方(任意地方都可以)
  B.打开tomcat目录下的server.xml文件并找到关于ssl的相关段
    Java代码
<!-- Define a SSL HTTP/1.1 Connector on port 8443 
This connector uses the JSSE configuration, when using APR, the   
connector should be using the OpenSSL style configuration  
described in the APR documentation -->  
<!--<Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true" 
maxThreads="150" scheme="https" secure="true" 
clientAuth="false"  sslProtocol="TLS" />-->  
    <!-- Define a SSL HTTP/1.1 Connector on port 8443
    This connector uses the JSSE configuration, when using APR, the
    connector should be using the OpenSSL style configuration
    described in the APR documentation -->
    <!--<Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
    maxThreads="150" scheme="https" secure="true"
    clientAuth="false"  sslProtocol="TLS" />-->
   
  C.去掉注释,添keystoreFile="C:\Tomcat\GMAE3.0Tomcat\tomcat.keystore"
  keystorePass="tomcat"的属性
  改动完成后配置为:
  Java代码
<Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"   maxThreads="150" scheme="https" secure="true" clientAuth="false" keystoreFile="C:\Tomcat\GMAE3.0Tomcat\tomcat.keystore" keystorePass="tomcat" sslProtocol="TLS" /> 
  <Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"   maxThreads="150" scheme="https" secure="true" clientAuth="false" keystoreFile="C:\Tomcat\GMAE3.0Tomcat\tomcat.keystore" keystorePass="tomcat" sslProtocol="TLS" />


  D.然后重启tomcat就能使用HTTPS访问
2.强制https访问
  在tomcat\conf\web.xml中的</welcome-file-list>后面加上这样一段:
Java代码
<login-config>  
    <!-- Authorization setting for SSL -->  
    <auth-method>CLIENT-CERT</auth-method>  
    <realm-name>Client Cert Users-only Area</realm-name>  
</login-config>  
<security-constraint>  
    <!-- Authorization setting for SSL -->  
    <web-resource-collection >  
        <web-resource-name >SSL</web-resource-name>  
        <url-pattern>/*</url-pattern>  
    </web-resource-collection>  
    <user-data-constraint>  
        <transport-guarantee>CONFIDENTIAL</transport-guarantee>  
    </user-data-constraint>  
</security-constraint> 
  <login-config>
      <!-- Authorization setting for SSL -->
      <auth-method>CLIENT-CERT</auth-method>
      <realm-name>Client Cert Users-only Area</realm-name>
  </login-config>
  <security-constraint>
      <!-- Authorization setting for SSL -->
      <web-resource-collection >
          <web-resource-name >SSL</web-resource-name>
          <url-pattern>/*</url-pattern>
      </web-resource-collection>
      <user-data-constraint>
          <transport-guarantee>CONFIDENTIAL</transport-guarantee>
      </user-data-constraint>
  </security-constraint>


































  ------------------------------------------------------------------------------------------------------------------------
  第一步:使用JDK自带的工具(KEYTOOL.EXE)生成证书
cmd>keytool -genkey -alias tomcat -keyalg RSA -keystore c:/mrj
输入相应资料即可
第二步:修改SERVICE.XML文件
在文件里面找到关于SSL定义的地方,于下面加入如下配置
<Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
maxThreads="150" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS" keystoreFile="C:\mrj" keystorePass="passwor"/>
其中 keystoreFile为生成的证书地址;keystorePass为证书密码
第三步:启动TOMCAT,在地址栏输入:https://localhost:8443查看效果
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值