開發環境:
前端:Vue+Stompjs
后端:Rabbitmq Web Stomp Plugin
Rabbitmq安裝插件:[rabbitmq_management,rabbitmq_mqtt,rabbitmq_stomp,rabbitmq_web_mqtt,rabbitmq_web_mqtt_examples,rabbitmq_web_stomp,rabbitmq_web_stomp_examples].
硬件環境:使用的阿里雲windos server2008系統
阿里雲中下載pfx證書。使用如下的代碼轉化成Rabbitmq需要配置的證書:
提取ca證書:
openssl pkcs12 -in 4000000_www.xxxx.com.pfx -nodes -password pass:域名證書密碼 -nokeys -cacerts -out cacert.pem
提取server證書:
openssl pkcs12 -in 4000000_www.xxxx.com.pfx -nodes -password pass:域名證書密碼 -nokeys -clcerts -out cert.pem
提取私鑰(密碼:123456)
openssl pkcs12 -in 4000000_www.xxxx.com.pfx -nodes -password pass:123456 -passout pass:123456 -nocerts -out private_key.pem
配置rabbitmq.conf文件需要配置如下內容:
listeners.ssl.default = 5671
ssl_options.verify = verify_peer
ssl_options.fail_if_no_peer_cert = false
ssl_options.cacertfile = C:\\RabbitMQServer\\certFiles\\cacert.pem
ssl_options.certfile = C:\\RabbitMQServer\\certFiles\\cert.pem
ssl_options.keyfile = C:\\RabbitMQServer\\certFiles\\private_key.pem
web_stomp.ssl.port = 15673
web_stomp.ssl.backlog = 1024
web_stomp.ssl.cacertfile = C:\\RabbitMQServer\\certFiles\\cacert.pem
web_stomp.ssl.certfile = C:\\RabbitMQServer\\certFiles\\cert.pem
web_stomp.ssl.keyfile = C:\\RabbitMQServer\\certFiles\\private_key.pem
web_stomp.ssl.password = 123456
前端Vue 連接配置:
Stomp.client('wss://www.xxxx.com:15673/ws');
如果不是阿里雲的話,需要使用openssl自制證書。
