我正在運行帶有嵌入式 keycloak 伺服器的 spring boot 3.2.1
<dependency> <groupid>org.pac4j</groupid> <artifactid>jakartaee-pac4j</artifactid> <version>8.0.0</version> </dependency> <dependency> <groupid>org.pac4j</groupid> <artifactid>pac4j-oidc</artifactid> <version>6.0.1</version> </dependency>
無需加密,一切正常,pac4j 能夠很好地處理事情。 當我使用 ssl bundle 引入 ssl 時,web 應用程式可以正常工作 (https),並且與嵌入式 keycloak 伺服器的交互也可以正常工作,包括以下呼叫: https://localhost:8888/auth/realms/master/.well-known/openid-configuration 在同一台機器上透過網頁瀏覽器製作時。 但是,在執行身份驗證過程時,pac4j 似乎會拋出以下錯誤:
org.pac4j.core.exception.TechnicalException: Error getting URL resource at org.pac4j.core.resource.SpringResourceHelper.getResourceInputStream(SpringResourceHelper.java:74) at org.pac4j.oidc.metadata.OidcOpMetadataResolver.retrieveMetadata(OidcOpMetadataResolver.java:89) at org.pac4j.oidc.metadata.OidcOpMetadataResolver.internalLoad(OidcOpMetadataResolver.java:76) at org.pac4j.core.resource.SpringResourceLoader.load(SpringResourceLoader.java:50) at org.pac4j.oidc.config.OidcConfiguration.findPkceMethod(OidcConfiguration.java:285) at org.pac4j.oidc.redirect.OidcRedirectionActionBuilder.addStateAndNonceParameters(OidcRedirectionActionBuilder.java:115) at org.pac4j.oidc.redirect.OidcRedirectionActionBuilder.getRedirectionAction(OidcRedirectionActionBuilder.java:58) at org.pac4j.core.client.IndirectClient.getRedirectionAction(IndirectClient.java:136) at org.pac4j.core.engine.DefaultSecurityLogic.redirectToIdentityProvider(DefaultSecurityLogic.java:240) at org.pac4j.core.engine.DefaultSecurityLogic.perform(DefaultSecurityLogic.java:160) at com.ebremer.server.MyCustomSecurityFilter.internalFilter(MyCustomSecurityFilter.java:79)
我在系統啟動時新增了trustallcertificates和trustallhostnames,但仍然沒有效果。
您需要使用自簽名憑證建立信任庫並將其指派給JVM:https://docs.oracle.com/cd /E29585_01/PlatformServices.61x/security/src/csec_ssl_jsp_start_server.html
#以上是Pac4J 使用自簽名憑證進行加密時遇到問題的詳細內容。更多資訊請關注PHP中文網其他相關文章!