本文主要是介绍serviceMix https搭建,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
1、ca的准备
1、建立某个ca根目录,用来进行ca证书的管理(例如:/opt/CA)。
2、在ca根目录下建立如下文件夹: newcerts、private,其中newcerts用于存放新生成的证书(openssl 自动管理),private用于存放自己的ca根证书的私钥。
3、将openssl目录中的openssl.cnf文件复制到该目录下,并将[ CA_default ]下的dir修改为第1步中的ca根目录/opt/CA,还要修改 [policy-match] ,将DName的匹配策略都改成optional。
4、在ca根目录下建立文件:空白文件index.txt、带有内容为01的文件serial
5、制作CA根证书(dname="CN=ca, OU=aa, O=bb, L=GZ, ST=Canton, C=CN")
openssl req -new -x509 -days 18900 -sha1 -newkey rsa:1024 -keyout /opt/CA/private/ca.key -out /opt/CA/ca.crt
2、自签名证书的生成
keytool -genkey -validity 13650 -keyalg RSA -keysize 1024 -keystore ./jetty.jks -alias jetty -dname "CN=ca, OU=aa, O=bb, L=GZ, ST=Canton, C=CN"
2、导出签名请求证书
keytool -certreq -sigalg MD5withRSA -file ./jettyReq.csr -keystore ./jetty.jks -alias jetty
3、生成自签名证书
openssl ca -in ./jettyReq.csr -out ./signedjetty.crt -notext -cert /opt/CA/ca.crt -keyfile /opt/CA/private/ca.key -config /opt/CA/openssl.cnf
4、将CA根证书的公钥导入服务端证书
keytool -import -v -trustcacerts -alias root -file /opt/CA/ca.crt -keystore ./jetty.jks
5、将自签名证书导入服务端证书
keytool -import -v -file ./signedjetty.crt -keystore ./jetty.jks
3、serverMix配置
1、在serviceMIX 安装目录下找到etc/org.ops4j.pax.web.cfg.empty.stub 文件
2、把该文件下的以下信息注解删除,并修改相应的信息
org.osgi.service.http.secure.enabled=true
org.ops4j.pax.web.ssl.keystore=E:/ca/jetty.jks
org.ops4j.pax.web.ssl.password=123456
org.ops4j.pax.web.ssl.keypassword=123456
org.osgi.service.http.port.secure=8443
3、把这文件重命名为
org.ops4j.pax.web.cfg
4、jetty.xml 加以下代码:
<Call name="addConnector">
<Arg>
<New class="org.eclipse.jetty.server.ssl.SslSelectChannelConnector">
<Set name="Port">8443</Set>
<Set name="maxIdleTime">30000</Set>
<Set name="Acceptors">2</Set>
<Set name="AcceptQueueSize">100</Set>
<Set name="Keystore">E:\ca\jetty.jks</Set>
<Set name="Password">123456</Set>
<Set name="KeyPassword">123456</Set>
<Set name="truststore">E:\ca\jetty.jks</Set>
<Set name="trustPassword">123456</Set>
</New>
</Arg>
</Call>
5、重启
这篇关于serviceMix https搭建的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!