什么是信息安全
信息安全主要包括以下三方面的内容:
保密性
真实性
完整性
如何保障数据安全?
保证信息安全的唯一途径 数据信息加密!!!
对称加密初体验
密码或密钥其实就是字符串或字节流
非对称加密原理
非对称密钥与证书的关系
非对称密钥: 公钥和对应私钥组成, 公钥加密, 私钥解密
证书: 以 .cert 结尾的文件, 可以嵌入在浏览器或其它客户端, 核心组件为公钥
证书应用
web 应用使用证书后, 证书被加载到浏览器, 使用 https 请求项目才会使用到证书
https 发起请求默认请求到服务器 443 端口(可自定义), 与 http 默认请求 80 端口原理一致
证书在 Tomcat 中的应用
使用 tomcat 做安全认证服务器, 自定义 https 命中 8443 端口
- <pre style="background-attachment: scroll; background-clip: border-box; background-color: rgb(244, 245, 246); background-image: none; background-origin: padding-box; background-position-x: 0%; background-position-y: 0%; background-repeat: repeat; background-size: auto; border-bottom-color: rgb(232, 232, 232); border-bottom-style: solid; border-bottom-width: 1px; border-image-outset: 0; border-image-repeat: stretch; border-image-slice: 100%; border-image-source: none; border-image-width: 1; border-left-color: rgb(232, 232, 232); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(232, 232, 232); border-right-style: solid; border-right-width: 1px; border-top-color: rgb(232, 232, 232); border-top-style: solid; border-top-width: 1px; box-sizing: border-box; color: rgb(153, 153, 153); font-family: Consolas,Menlo,Courier,monospace; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; line-height: 1.5; margin-bottom: 1em; margin-left: 0px; margin-right: 0px; margin-top: 1em; orphans: 2; padding-bottom: 12px; padding-left: 10px; padding-right: 10px; padding-top: 12px; position: relative; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-tap-highlight-color: transparent; -webkit-text-stroke-width: 0px; white-space: pre-wrap; word-spacing: 0px;">
- 1. keytool -genkey -v -alias tomcat -keyalg RSA -validity 36500 -keystore
- e:\tomcat.keystore -dname "CN=localhost,OU=cn,O=cn,L=cn,ST=cn,c=cn" -storepass
- password -keypass password 2. keytool -export -alias tomcat -keystore e:\tomcat.keystore
- -file e:\tomcat.cer -storepass password 3.
- <Connector port="8443" protocol="org.apache.coyote.http11.Http11Protocol"
- SSLEnabled="true" maxThreads="150" scheme="https" secure="true" clientAuth="false"
- sslProtocol="TLS" keystoreFile="E:/tomcat.keystore" keystorePass="password"
- />
- </pre>
来源: http://www.jianshu.com/p/9964c0e2d7f4