5

keycloak~docker部署https的keycloak使用自定义证书

 3 years ago
source link: https://www.cnblogs.com/lori/p/15094837.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

使用自定义证书

需要先生成一对证书,其中.crt文件是公钥,也叫证书,在浏览器上可以看到;.key文件是私钥,由网站服务器自己保留。

keycloak ssl

  • keycloak的ssl默认有自己的自签名证书,这个如果涉及到你的程序调用kc的接口,kc使用自定义证书是不行的,你调不通,使用使用正规的证书
  • ssl的https端口是8443,在使用docker启动时,监听它即可
  • ssl的自定义证书目录是/etc/x509/https,使用docker时,把自定义证书挂载到这个目录即可

为什么要使用https

对于跨站共享cookie来说,你需要使用samesite,secure等属性,而samesite:none这个是可以跨站的,而它依赖于secure:true,而这个值它只有在https协议下才有效!

docker启动ssl的keycloak

docker rm -f keycloak && docker run --name keycloak -d \
-p 8443:8443  \
-p 8080:8080  \
-e KEYCLOAK_USER=admin \
-e KEYCLOAK_PASSWORD=admin \
-e DB_VENDOR=MYSQL \
-e DB_ADDR=192.168.1.5\
-e DB_DATABASE=keycloak \
-e DB_USER=root \
-e DB_PASSWORD=123456 \
-e JDBC_PARAMS='useSSL=false' \
-e TZ=Asia/Shanghai \
-e LANG=zh_CN.GB2312  \
-v /etc/localtime:/etc/localtime  \
-v /root/jar/target/cert/:/etc/x509/https \
--privileged=true \
--restart=always \
--add-host kafka1:192.168.1.5
jboss/keycloak

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK