2024-07-12
한어Русский языкEnglishFrançaisIndonesianSanskrit日本語DeutschPortuguêsΕλληνικάespañolItalianoSuomalainenLatina
Since the applet requires access to the wss interface, the test environment needs to be switched to https. I read the official documentation.
RabbitMQ Web STOMP Plugin | RabbitMQThere is this information in it
Then I typed GPT for a while, inputting the requirements several times, and got a script like this:
generate_cert.sh
- #!/bin/bash
-
- # 检查是否提供了IP地址
- if [ "$#" -ne 1 ]; then
- echo "Usage: $0 <IP_ADDRESS>"
- exit 1
- fi
-
- IP_ADDRESS=$1
- PASSWORD="changeme"
-
- # 创建必要的目录
- mkdir -p certs
-
- # 生成 CA 密钥
- openssl genrsa -des3 -passout pass:$PASSWORD -out certs/ca.key 2048
-
- # 生成 CA 证书
- openssl req -x509 -new -nodes -key certs/ca.key -sha256 -days 1024 -passin pass:$PASSWORD -out certs/ca_certificate.pem -subj "/CN=${IP_ADDRESS}"
-
- # 生成服务器密钥
- openssl genrsa -des3 -passout pass:$PASSWORD -out certs/server.key 2048
-
- # 生成服务器证书签名请求(CSR)
- openssl req -new -key certs/server.key -passin pass:$PASSWORD -out certs/server.csr -subj "/CN=${IP_ADDRESS}"
-
- # 创建一个配置文件用于扩展
- cat <<EOF > certs/openssl.cnf
- [ v3_ca ]
- basicConstraints = CA:TRUE
- [ v3_req ]
- basicConstraints = CA:FALSE
- subjectAltName = @alt_names
- [ alt_names ]
- IP.1 = ${IP_ADDRESS}
- EOF
-
- # 使用 CA 证书签署服务器证书
- openssl x509 -req -in certs/server.csr -CA certs/ca_certificate.pem -CAkey certs/ca.key -CAcreateserial -out certs/server_certificate.pem -days 500 -sha256 -passin pass:$PASSWORD -extfile certs/openssl.cnf -extensions v3_req
-
- # 转换服务器密钥为 PEM 格式
- openssl rsa -in certs/server.key -out certs/server_key.pem -passin pass:$PASSWORD -passout pass:$PASSWORD
-
- # 打印完成信息
- echo "Certificates and keys generated successfully in the 'certs' directory."
- echo "CA Certificate: certs/ca_certificate.pem"
- echo "Server Certificate: certs/server_certificate.pem"
- echo "Server Key: certs/server_key.pem"
Use in Ubuntu of WSL
generate_cert.sh <test IP> to generate
Then create rabbitmq.conf in the log/db directory of the RabbitMQ server
Paste the content of the first picture, then restart the rabbitMQ service, and then look at the management interface. The https port 15673 is successfully started.