- 浏览: 174066 次
- 性别:
- 来自: 上海
文章分类
- 全部博客 (174)
- rails (25)
- js (15)
- ruby (30)
- webserver (5)
- mysql (13)
- security (5)
- thinking (5)
- common sense (2)
- linux (18)
- android (26)
- web browser (1)
- config and deploy (1)
- mac (5)
- css (2)
- db (8)
- version manager (1)
- editor (1)
- job (1)
- OOA (1)
- php (1)
- apache (2)
- mongrel (1)
- Mongodb (1)
- facebook (1)
- 架构 (1)
- 高并发 (1)
- twitter (1)
- Erlang (1)
- Scala (1)
- Lua (1)
- ubuntu (3)
- cache (1)
- 面试题 (2)
- android layout (2)
- android控件属性 (2)
- java (5)
- customize view (1)
- advanced (2)
- python (2)
- 机器学习 (5)
最新评论
cd /usr/local/jdk/bin
./keytool -list -keystore /home/pingan/stg.jks -storepass 12345678
cd
openssl pkcs12 -info -in stg.pfx
JKS(JavaKeysotre)格式和PFX(PKCS12)格式,是最常见的SSL证书格
式文件,可以包含完整的证书密钥对,证书链和信任证书信息。PFX常
用于Windows IIS服务器,JKS常用于JAVA类的WEB服务器,
如TOMCAT,WEBLOGIC,JBOSS,RESIGN。虽然近年来,这些服务器新
的版本,都是可以同时支持PFX,JKS文件格式了,但是老的版本和
免费版本,往往都只支持JKS格式,所以当我们在不同WEB平台切换的
时候,就要转换现有的SSL证书格式。
1. PFX文件转换为JKS文件
使用JWSDP工具包中的工具
安装J2SE 1.5,下载并运行jdk-1_5_0_09-windows-i586-p.exe
下载并安装jave web service develop pack, jwsdp-2_0-windows-i586.exe
创建一个新的keystore文件,里面的别名取做TEMP
keytool -genkey -alias temp -keyalg RSA -keystore server.jks
准备好要导入的PFX文件,server.pfx,运行:
C:\Sun\jwsdp-2.0\xws-security\bin\pkcs12import.bat pkcs12import -file server.p12 -alias server -keystore server.jks
查看server.jks 里面的证书记录:
keytool -list -v -keystore server.jks
2. JKS文件转换为PFX文件
通过jks2pfx工具
请下载:JKS2PFX转换工具。
将压缩包解开到 c:\jks2pfx 目录下,
运行以下命令:
JKS2PFX <导出文件名> [Java Runtime的目录]
备注:
KeyStore文件:指Tomcat保存SSL证书的文件
KeyStore密码:KeyStore文件对应的密码
Alias别名: 生成证书CSR时,所起的Alias别名
导出文件名: 准备导出的文件名称 (不要带扩展名)
Java Runtime的目录(可选): 指包含Java.exe和keytool.exe的目录,如:c:\progra~1\Java\jre1.5.0_06\bin
例如:
JKS2PFX server.jks 123456 tomcat exportfile c:\progra~1\Java\jre1.5.0_06\bin
该命令将server.jks中别名为tomcat的SSL证书导出,运行后将产生3个文件 exportfile.key、exportfile.crt、exportfile.pfx,exportfile.pfx可以导入到微软的IIS中,exportfile.key和exportfile.crt 可用于Apache或者OpenSSL兼容的系统。
可以用下面命令查看PFX文件内容:
openssl pkcs12 -info -in exportfile.pfx
3.PFX文件转换为X509证书文件和RSA密钥文件
通过Openssl命令行
openssl pkcs12 -in myssl.pfx -nodes -out server.pem
openssl rsa -in server.pem -out server.key
openssl x509 -in server.pem -out server.crt
openssl pkcs12 -in pkcs-12-certificate-file -out pem-certificate-file
openssl pkcs12 -in pkcs-12-certificate-and-key-file -out pem-certificate-and-key-file
===============================================================
ruby Net::HTTP
cd /usr/local/jdk/bin
./keytool -list -keystore /home/simon/abc.jks -storepass 12345678
openssl pkcs12 -info -in abc.pfx
PEM file: *.pem
Keystore file: *.jks
PKCS12 file: *.pfx
pfx => pem
openssl pkcs12 -in abc.pfx -nodes -out client.pem
Enter Import Password:
jks => pem
./keytool -exportcert -keystore /home/simon/javapro/TestPost/abc.jks -file /home/simon/mycert.crt -alias mykey
openssl x509 -out /home/simon/cert/key/key.pem -outform pem -in /home/simon/mycert.crt -inform der
jks => pem
cd to /usr/local/jdk/bin
./keytool -importkeystore -srckeystore /home/simon/javapro/TestPost/abc.jks -destkeystore /home/simon/javapro/TestPost/key.pfx -srcstoretype JKS -deststoretype PKCS12
./keytool -importkeystore -srckeystore /home/simon/javapro/TestPost/abc.jks -destkeystore /home/simon/javapro/TestPost/key.pfx -srcalias mykey -srcstoretype jks -deststoretype pkcs12
./keytool -importkeystore -srckeystore /home/simon/javapro/TestPost/abc.jks -destkeystore /home/simon/javapro/TestPost/key.pfx -srcstoretype jks -deststoretype pkcs12
=========================================
bash$ keytool -keystore foo.jks -genkeypair -alias foo \
-dname 'CN=foo.example.com,L=Melbourne,ST=Victoria,C=AU'
bash$ keytool -keystore foo.jks -exportcert -alias foo | \
openssl x509 -inform der -text
bash$ keytool -importkeystore -srckeystore foo.jks \
-destkeystore foo.p12 \
-srcstoretype jks \
-deststoretype pkcs12
bash$ openssl pkcs12 -in foo.p12 -out foo.pem
bash$ openssl x509 -text -in foo.pem
bash$ openssl dsa -text -in foo.pem
You end up with:
foo.jks - keystore in java format.
foo.p12 - keystore in PKCS#12 format.
foo.pem - all keys and certs from keystore, in PEM format.
(This last file can be split up into keys and certificates if you like.)
Command summary - to create JKS keystore:
keytool -keystore foo.jks -genkeypair -alias foo \
-dname 'CN=foo.example.com,L=Melbourne,ST=Victoria,C=AU'
Command summary - to convert JKS keystore into PKCS#12 keystore, then into PEM file:
keytool -importkeystore -srckeystore foo.jks \
-destkeystore foo.p12 \
-srcstoretype jks \
-deststoretype pkcs12
openssl pkcs12 -in foo.p12 -out foo.pem
if you have more than one certificate in your JKS keystore, and you want to only export the certificate and key associated with one of the aliases, you can use the following variation:
keytool -importkeystore -srckeystore foo.jks \
-destkeystore foo.p12 \
-srcalias foo \
-srcstoretype jks \
-deststoretype pkcs12
openssl pkcs12 -in foo.p12 -out foo.pem
Command summary - to compare JKS keystore to PEM file:
keytool -keystore foo.jks -exportcert -alias foo | \
openssl x509 -inform der -text
openssl x509 -text -in foo.pem
openssl dsa -text -in foo.pem
openssl pkcs12 -in myapp.p12 -nodes -out key.pem
Enter Import Password:
pfx => pem
openssl pkcs12 -in /home/simon/javapro/TestPost/abc.pfx -nodes -out /home/simon/key.pem
Enter Import Password:
extract rsa:
openssl rsa -in /home/simon/javapro/TestPost/key.pem -outform pem -out /home/simon/cert/key/key.pem
jks => pem
./keytool -exportcert -keystore /home/simon/javapro/TestPost/abc.jks -file /home/simon/mycert.crt -alias mykey
pwd:
openssl x509 -out /home/simon/cert/key/client.pem -outform pem -in /home/simon/mycert.crt -inform der
========================================
jks(java key store):
java用的存储密钥的容器。可以同时容纳n个公钥或私钥,后缀一般是.jks或者.keystore或.truststore等,千奇百怪。
不管什么后缀,它就是一个容器,各个公司或机构叫法不同而已。比如把只包含"受信任的公钥"的容器存成.truststore文件等。
用jdk\bin目录下的keytool.exe对其进行查看,导入,导出,删除,修改密码等各种操作。
可以对jks容器加密码,输入正确才可以操作此容器中密钥。
还有一个密码的概念与上者不同,是jks中存储着的私钥的密码,通常是绝密的。
pfx:
和jks功能相同但文件格式不同,pfx是浏览器用的。
可以用一些工具程序把pfx转化成jks格式供java程序使用(如银行只提供了pfx,但是我们想用httpclient模拟浏览器自动访问时)。
据说IE导出的pfx格式不标准,转化jks时往往报错,可以尝试用Netscape Navigator导入再导出,然后再转化。碰到过这样的情况。
常见的几种https系统的访问
经https协议的数据经过加密传输,防止第三方监听,冒充和篡改。
1.不需要用户做任何操作,比如https://www.verisign.com/
这是因为此公钥是合法的(公钥是可信任的机构颁发,和实际域名吻合,而且没有到期)。用IE访问时空白处点右键可以查看公钥信息。
2.https的页面会弹出公钥确认提示
公钥不合法(不是可信任的机构颁发,和实际域名不吻合,已到期),但用户点“是”即表示忽略危险,继续访问。
3.需要往浏览器倒入一个文件才可访问的
一般是银行在线交易等特别需要安全的场合,站方(银行)需要验证访客身份(如要确认必须是已注册的网银商户),需要在浏览器中导入含有访客私钥的pfx文件。
生成jks:
在银行没有提供jks文件的情况下对帐,需要自己生成jks
对于1,2类https网站,如果java程序访问此地址时在jre默认的信任库中找不到对方证书的颁发机构,则会抛出安全方面的异常。
所以要将站方公钥存进一个jks,并在环境变量中设定,表明信任此库中的公钥,才可以正常访问。
我是用现成的make_jks的工具类在程序中读取https://xxxx地址,程序自动抓取出银行公钥并存进一个jks文件。
在浏览器中查看站方公钥时,把公钥导出(一般是cer后缀),然后用keytool.exe手工将此cer导入一个jks或许也可以?没试过。
以上1,2类https网站,仅仅是用到了公钥的“验证对方身份”功能。
对于第3种https网站,也可以找到现成的程序把pfx直接转成jks。
既然动用了pfx,一般是把公钥的两个用途和私钥的两个用途都用起来。
========================================
In a TLS/SSL connection, a public key is supplied as part of a certificate that is used to authenticate one party - the certificate ties an identity to a particular public key. The server side always supplies a certificate (public key), because the server side must always prove its identity to the client.
It is also possible for the client to supply a certificate, if it wants to prove its identity (and it has a suitable certificate) - in your web browser example, it's usually the case that a client certificate isn't supplied, but it is possible. Some web sites do use client certificates for authentication.
If a public key is used, the corresponding private key must be used too - the keys come as a pair. The corresponding function to supply the public key is SSL_CTX_use_certificate() - the public key is part of the certificate. Supplying one without the other is pointless - in your client example, you could have omitted the call to SSL_CTX_use_PrivateKey_file() entirely.
===================================
=>Using Net::HTTP to proxy HTTPS
As far as I can tell from my experimenting, there is no way to proxy HTTPS requests using the Net::HTTP classes. My question is: can it be done? And if so, how?I've tried numerous variations, but the main gist of what I've tried is this code fragment: httpobj = Net::HTTP.new( host, port )
=>Using Net::HTTP to prod google adwords api
Hi,I've been trying to use Net::HTTP with a SOAP (xml) document to query google adwords api. The reason for wanting to do this, is that I'v estumbled across a problem with one of the methods when using adwords4r. I wanted to eliminate adwords4r and soap4r from the equation, hence trying to
相关推荐
弱哈希算法签名的SSL证书(CVE-2004-2761)。 远程服务使用SSL证书链,该证书链已使用加密弱哈希算法(例如MD2、MD4、MD5或SHA1)签名。这些签名算法很容易受到碰撞攻击。攻击者可以利用这一点生成另一个具有相同数字...
android ssl证书验证
弱哈希算法签名的SSL证书(CVE-2004-2761)。 远程服务使用SSL证书链,该证书链已使用加密弱哈希算法(例如MD2、MD4、MD5或SHA1)签名。这些签名算法很容易受到碰撞攻击。攻击者可以利用这一点生成另一个具有相同数字...
功能:有时候我们在本地调试网站,需要本地的SSL证书。这个工具就是为生成SSL证书工具CreateCertGUICreateCertGUI而生。 备注:可以不限量免费生成生成SSL证书
域名SSL证书在线生成系统_SSL在线自签证书工具_免费SSL在线生成源码 源码没有后台没有数据库,源码简单便捷,上传到空间内即可使用,虚拟主机,vps,服务器,甚至二级目录,都可以,方便快捷! 随时可以生成自己的...
windows 2003环境SSL证书安装
通过OpenSSL生成的ssl证书,用于windows下用nginx配置https服务器( OpenSSL创建证书) 无需再下载OpenSSL,配置OpenSSL相关环境,在进行命令生成证书
2023最新SSL证书在线申请系统源码 | 支持API接口 SSL证书保证网络安全的基本保障。向您介绍我们的在线生成SSL证书系统 支持在线生成SSL证书系统,用户登录可在线申请SSL,后台对接ssl证书API接口 测试运行环境:...
自己颁发SSL证书浏览器不识别解决方法 【SSL证书的类型】 在了解自己颁发SSL证书浏览器不识别解决方法之前,我们需要了解SSL证书的类型。SSL证书可以分为两种: Domain Validation(DV)和Extended Validation(EV...
在Centos7.6平台下使用openssl给apache做自签名证书,并给apache设置HTTPS的SSL证书。(无坑版) 二、平台 [root@kahn.xiao ~]# uname -r 3.10.0-957.el7.x86_64 [root@kahn.xiao ~]# cat /etc/redhat-release ...
这是一款二次元风格向的SSL证书自签工具源码,可随时随地签发SSL证书 运行环境: 你的 PHP 必须 >=5.6,且安装了 OpenSSL 扩展 所有文件都已本地化,大部分PHP默认开启OpenSSL 安装: 下载源码导入网站目录访问...
很好的额ssl证书 生成和管理工具,方便下载
java信任SSL证书的工具类 忽略HTTPS请求的SSL证书,必须在openConnection之前调用
本地ssl证书生成工具
windows服务器,PHPStudy(小皮)服务环境下,ssl证书批量替换工具,不用一个一个的去更新替换
window下ssl证书制作生成工具,用于弱哈希算法签名的SSL证书升级成sha256算法签名证书,关于漏洞CVE-2004-2761
SSL证书生成软件、包括转换证书格式
访问带https请求忽略ssl证书,避免url.openStream报错javax.net.ssl.SSLHandshakeException url = new URL(imageUrl); if("https".equalsIgnoreCase(url.getProtocol())){ SslUtils.ignoreSsl(); } //不添加...
【免费申请SSL证书】申请免费的SSL证书(三)__手把手教SSL证书自动续期
SSL证书安装并且包括Apache服务器安装ssl证书、iis服务器安装ssl证书、Nginx服务器安装ssl证书、Tomcat服务器安装证书