简体   繁体   English

QuickFIX / J CA证书验证

[英]QuickFIX/J CA Certificate Validation

I have an application written using QuickFIX/J to connect with Bloomberg Server. 我有一个使用QuickFIX / J编写的与彭博服务器连接的应用程序。 Recently Bloomberg added CA certificate validation to their servers and they provide additional CA certificate file for handshaking. 最近,彭博社向其服务器添加了CA证书验证,并且它们还提供了用于握手的其他CA证书文件。

My application connected using SSL and when disable CA certificate validation from Bloomberg side, application successfully connect to server and get the messages. 我的应用程序使用SSL连接,并且在从Bloomberg端禁用CA证书验证时,应用程序成功连接到服务器并获取消息。 Handshaking failed when enable CA validation. 启用CA验证时,握手失败。

Below are the steps I tried. 以下是我尝试的步骤。

  1. Previously i'm using ImportKey Java class to add certificate and key. 以前,我使用ImportKey Java类添加证书和密钥。 I changed it to add multiple certificates. 我将其更改为添加多个证书。 If need I can post the Java class. 如果需要,我可以发布Java类。
  2. When I connect to the server using openssl s_client it successfully connects to the server. 当我使用openssl s_client连接到服务器时,它成功连接到服务器。

Is there anything that needs to be changed on Application level? 在应用程序级别需要更改什么吗? Configuration? 组态? Or is there anything to do in the Java keystore level? 还是在Java密钥库级别有什么要做?

Error message comes when connecting is added below: 在下面添加连接时出现错误消息:

20160823-06:04:15, FIX.4.4:XXXX->XXXX, error> (Disconnecting: Socket exception (/XXXX.XXXX.XXX.XX:20237): javax.net.ssl.SSLHandshakeException: SSL handshake failed.) Successfully logged out for sessionId : FIX.4.4:XXXX->XXXX 20160823-06:04:15,FIX.4.4:XXXX-> XXXX,错误>(正在断开连接:套接字异常(/XXXX.XXXX.XXX.XX:20237):javax.net.ssl.SSLHandshakeException:SSL握手失败。)成功注销sessionId:FIX.4.4:XXXX-> XXXX

Any help is appreciated! 任何帮助表示赞赏!


The configuration: 配置:

[default]
# Settings which apply to all the Sessions.

ConnectionType=initiator
LogonTimeout=86400
ResetOnLogon=Y
UseDataDictionary=Y
MaxLatency=240

#StartTime=00:00:00
#EndTime=00:00:00

#StartTime=02:30:00
#EndTime=12:30:00

StartTime=02:21:00
EndTime=12:21:00

HeartBtInt=30
ReconnectInterval=5

[session]
# Settings specifically for one session
BeginString=FIX.4.4
SocketConnectHost=xxx.xxx.xxx.xxx
SocketUseSSL=Y
SocketKeyStorePassword=importkey
CheckLatency=N

#SendResetSeqNumFlag=Y

# new setups

FileLogHeartbeats=Y
##----- CAPS Configuration ---------##

FileStorePath=/etc/bloomburg-live/msgs
FileLogPath=/etc/bloomburg-live/logs
DataDictionary=/etc/bloomburg-live/conf/FIX44.xml
SocketKeyStore=/root/.keystore
TargetCompID=BLPSTP
SocketConnectPort=xxxxx
SenderCompID=CAPSTP

# log configuration

FileIncludeMilliseconds=Y
FileIncludeTimeStampForMessages=Y
ScreenLogShowHeartBeats=Y       
#Filter heartbeats from output (both incoming and outgoing)

PS - Application work without CA certificate validation. PS-无需CA证书验证的应用程序工作。 Error comes when enabling CA certificate validation. 启用CA证书验证时出现错误。

Yes, If the application previously worked with ssl. 是的,如果该应用程序以前使用过ssl。 You dont need to do any changes in the application side. 您不需要在应用程序端进行任何更改。 Normally Quickfix/j is processing ssl validation just like java. 通常,Quickfix / j像Java一样处理ssl验证。 That means openssl and the java keytool will do the trick for you. 这意味着openssl和Java keytool将为您解决问题。 So steps are listed below. 因此,步骤在下面列出。

  1. Create pkcs12 keystore using trust certificate, private key and ca certificate. 使用信任证书,私钥和ca证书创建pkcs12密钥库。
 $ openssl pkcs12 -export -chain -in certificate.pem -inkey encodedKey.pem -out keystore.p12 -name importkey -CAfile CAcertificate.pem 

Enter Export Password: importkey Verifying - Enter Export Password: importkey 输入导出密码:importkey验证-输入导出密码:importkey

  1. Using keytool, import the PKCS12 keystore into the resulting keystore using by the quickfix/j called /root/.keystore. 使用keytool,通过名为/root/.keystore的quickfix / j将PKCS12密钥库导入到生成的密钥库中。 Again, you may select different passwords. 同样,您可以选择其他密码。
 keytool -importkeystore -destkeystore /root/.keystore -srckeystore keystore.p12 -alias importkey Enter destination keystore password: importkey Re-enter new password: importkey Enter source keystore password: importkey 
  1. Change the configuration file and copy the keystore to the class path. 更改配置文件,然后将密钥库复制到类路径。
 SocketKeyStore=keystore.ImportKey cp /root/.keystore keystore.ImportKey /your/classpath 

Thats it. 而已。 Please note, Adding ssl key and certificates to the java keystore is not working for quickfix/j due to quickfix/j is maintaining its own keystore. 请注意,由于quickfix / j会维护自己的密钥库,因此无法向quickfix / j添加ssl密钥和证书到Java密钥库。 So make sure you add the keystore to the class path after the key adding process. 因此,请确保在密钥添加过程之后将密钥库添加到类路径。

Reference - https://blogs.oracle.com/jtc/entry/installing_trusted_certificates_into_a 参考-https: //blogs.oracle.com/jtc/entry/installing_trusted_certificates_into_a

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM