oracle OHS配置https证书

背景

目前ohs服务器上已有自签名证书,客户购买了第三方证书要求把自签名换成第三方证书,客户提供证书如下:

《oracle OHS配置https证书》

for apache

一开始想当然用for Apache里面的证书,因为ohs前身就是apache,这也是所有坑的开始。
证书制作过程很顺利,但在重启服务器时报以下错误:

*** glibc detected *** /u01/app/Oracle/Middleware/Oracle_WT1/ohs/bin/httpd.worker: free(): invalid pointer: 0x000000000c6ce1f0 ***
======= Backtrace: =========
/lib64/libc.so.6[0x3de6c7230f]
/lib64/libc.so.6(cfree+0x4b)[0x3de6c7276b]
/u01/app/Oracle/Middleware/Oracle_WT1/lib/libnnz11.so(nzumfree+0x64)[0x2b707d26b876]
/u01/app/Oracle/Middleware/Oracle_WT1/lib/libnnz11.so(nztiFIC_Free_Identity_Contents+0x45)[0x2b707d29adef]
/u01/app/Oracle/Middleware/Oracle_WT1/lib/libnnz11.so(nztiDI_Destroy_Identity+0x3a)[0x2b707d29ad84]
/u01/app/Oracle/Middleware/Oracle_WT1/lib/libnnz11.so(nztiFIL_Free_Identity_List+0x5a)[0x2b707d29ad36]
/u01/app/Oracle/Middleware/Oracle_WT1/lib/libnnz11.so(nztnFPC_Free_Persona_Contents+0x45)[0x2b707d29ecb5]
/u01/app/Oracle/Middleware/Oracle_WT1/lib/libnnz11.so(nztnDAP_Destroy_A_Persona+0x41)[0x2b707d29ec51]
/u01/app/Oracle/Middleware/Oracle_WT1/lib/libnnz11.so(nztnFPL_Free_Persona_List+0x56)[0x2b707d29ec00]
/u01/app/Oracle/Middleware/Oracle_WT1/lib/libnnz11.so(nztwFWC_Free_Wallet_Contents+0x70)[0x2b707d2a12e6]
/u01/app/Oracle/Middleware/Oracle_WT1/lib/libnnz11.so(nzos_OpenWallet+0x3d)[0x2b707d2b0071]
/u01/app/Oracle/Middleware/Oracle_WT1/ohs/modules/mod_ossl.so[0x2b70800adeff]
/u01/app/Oracle/Middleware/Oracle_WT1/ohs/modules/mod_ossl.so(is_sso_wallet+0x1a)[0x2b70800ae010]
/u01/app/Oracle/Middleware/Oracle_WT1/ohs/modules/mod_ossl.so[0x2b70800ae4a2]
/u01/app/Oracle/Middleware/Oracle_WT1/ohs/modules/mod_ossl.so(ssl_pphrase_Handle+0x13d)[0x2b70800af075]
/u01/app/Oracle/Middleware/Oracle_WT1/ohs/modules/mod_ossl.so(ssl_init_Module+0x229)[0x2b70800a5deb]
/u01/app/Oracle/Middleware/Oracle_WT1/ohs/bin/httpd.worker(ap_run_post_config+0xc8)[0x44fcd0]
/u01/app/Oracle/Middleware/Oracle_WT1/ohs/bin/httpd.worker(main+0x10ad)[0x42debf]
/lib64/libc.so.6(__libc_start_main+0xf4)[0x3de6c1d994]
/u01/app/Oracle/Middleware/Oracle_WT1/ohs/bin/httpd.worker(apr_bucket_mmap_make+0x5a)[0x426bea]

目测无法解决,google和sr上也没有好的解决方案。
因为一直死磕apache,几乎绝望,怀疑证书问题,想到客户证书是Wosign公司签发的,就去wosign的官网,在官网上发现了这张图片,才突然意识到apache文件夹里没有中间证书,巨坑啊。

《oracle OHS配置https证书》
至此放弃apache选择other server。

步骤

开始介绍正常正如何导入ohs。

  1. 用文本编辑器打开root证书和所有中间证书,合并成一个文件,文件名为ca.crt。保留标识符“-----BEGIN CERTIFICATE-----“”-----END CERTIFICATE-----“,合并后的文件格式如下:
-----BEGIN CERTIFICATE-----
.....
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
.....
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
.....
-----END CERTIFICATE-----
  1. 将私钥文件 server.key,用户文件server.crt,第1步合并后的ca.crt上传到ohs服务器。
-rw-r--r-- 1 oracle oinstall 4503 Jun  8 01:51 ca.crt
-rwxr-xr-x 1 oracle oinstall 2061 Jun  8 01:50 server.crt
-rwxr-xr-x 1 oracle oinstall 1700 Jun  8 01:50 server.key
  1. 用openssl将证书转换成 PKCS #12类型
openssl pkcs12 -export -in server.crt -inkey server.key -certfile ca.crt -out ewallet.p12

openssl会要求输入密码,该密码不能为空,命令执行完后会生成ewallet.p12文件
对于第三方证书,ohs目前只支持这种类型,并且生成的文件名ewallet.p12也不能修改

《oracle OHS配置https证书》

  1. 使用vnc登录ohs服务器,这里需要借助一个gui工具owm,将生成的证书修改为auto login,即无密码登录,不然ohs启动会报错。

该工具位于$MW_HOME/Oracle_WT1/bin/owm,如/u01/app/Oracle/Middleware/Oracle_WT1/bin/owm
启动后点击菜单Wallet->Open,会询问是否继续,选择YES后选择包含ewallet.p12的文件夹,输入第3步所指定的密码。

《oracle OHS配置https证书》
选择菜单wallet,把Auto Login勾选上,保存退出

《oracle OHS配置https证书》
此时ewallet.p12 所在的文件夹下会多出一个文件cwallet.sso

-rw-r--r-- 1 oracle oinstall 4503 Jun  8 01:51 ca.crt
-rw------- 1 oracle oinstall 6453 Jun  8 02:05 cwallet.sso
-rw------- 1 oracle oinstall 6421 Jun  8 02:05 ewallet.p12
-rwxr-xr-x 1 oracle oinstall 2061 Jun  8 01:50 server.crt
-rwxr-xr-x 1 oracle oinstall 1700 Jun  8 01:50 server.key
  1. 在$MW_HOME/Oracle_WT1/instances/instance1/config/OHS/ohs1/keystores下创建一个文件夹保存证书文件,文件名自取,这里以demo为例,复制cwallet.ssoewallet.p12两个文件到demo文件夹下
  2. 修改$MW_HOME/Oracle_WT1/instances/instance1/config/OHS/ohs1/ssl.conf文件

 SSLWallet "${ORACLE_INSTANCE}/config/${COMPONENT_TYPE}/${COMPONENT_NAME}/keyss
tores/default"

修改为

SSLWallet "${ORACLE_INSTANCE}/config/${COMPONENT_TYPE}/${COMPONENT_NAME}/keyss
tores/demo"

保存退出,重启ohs服务器,访问https://host:4443验证证书是否导入成功,至于如何将4443端口修改为默认的443端口,后面再说,也是一件麻烦的事。

后记

之所以折腾到这么晚,总结了一下原因:

  1. 没真正理解ssl原理,盲目选择apache证书
  2. 心浮气躁,懒得去看原理,急于解决错误,搞技术的不该心浮气躁。

补充

2017-06-15 oracle ohs修改https端口

    原文作者:wls1036
    原文地址: https://segmentfault.com/a/1190000020476617
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞