- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在研究中央认证系统 (jasig.org) 以实现单点登录功能对于我的 Intranet Web 应用程序。我有两个 tomcat 实例在我的同一台机器(windows)上运行。两个 tomcat 实例都已配置为使用 SSL 并使用了自签名证书(使用 java keytool 创建)。
Cas 服务器。
<Connector port="8443" maxHttpHeaderSize="8192" SSLEnabled="true"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" disableUploadTimeout="true"
acceptCount="100" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS"
keystoreFile="C:/Users/sandip.paul/.keystore"
keystorePass="changeit"
truststoreFile="C:/Program Files/Java/jdk1.6.0_20/jre/lib/security/cacerts" />
myWebApp(使用 spring security)
<Connector port="8663" maxHttpHeaderSize="8192" SSLEnabled="true"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" disableUploadTimeout="true"
acceptCount="100" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS" />
下面是myWebApp的applicationContext-security.xml文件
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:security="http://www.springframework.org/schema/security"
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-2.0.4.xsd">
<!--
Enable security, let the casAuthenticationEntryPoint handle all intercepted urls.
The CAS_FILTER needs to be in the right position within the filter chain.
-->
<security:http entry-point-ref="casProcessingFilterEntryPoint" auto-config="true">
<security:intercept-url pattern="/protected/**" access="IS_AUTHENTICATED_FULLY" />
</security:http>
<!--
Required for the casProcessingFilter, so define it explicitly set and
specify an Id Even though the authenticationManager is created by
default when namespace based config is used.
-->
<security:authentication-manager alias="authenticationManager" />
<!--
This section is used to configure CAS. The service is the
actual redirect Client URL that will be triggered after the CAS login sequence.
-->
<bean id="serviceProperties" class="org.springframework.security.ui.cas.ServiceProperties">
<property name="service" value="https://obll1973.abc.com:8663/myWebApp/j_spring_cas_security_check"/>
<property name="sendRenew" value="false"/>
</bean>
<!--
The customUserDetailsService provides ROLE & other Details and
create an object of UserDetail for this application.
-->
<bean id="customUserDetailsService"
class="edu.sandip.cas.client.authentication.CustomUserDetailsService">
</bean>
<!--
The CasProcessingFilter has very similar properties to the
AuthenticationProcessingFilter (used for form-based logins).
The CAS Processing filter handles the redirect from the CAS server
and starts the ticket validation.
-->
<bean id="casProcessingFilter" class="org.springframework.security.ui.cas.CasProcessingFilter">
<security:custom-filter after="CAS_PROCESSING_FILTER"/>
<property name="authenticationManager" ref="authenticationManager"/>
<property name="authenticationFailureUrl" value="/casfailed.jsp"/>
<property name="defaultTargetUrl" value="/"/>
</bean>
<!--
The entryPoint intercepts all the CAS authentication requests.
It redirects to the CAS loginUrl for the CAS login page.
-->
<bean id="casProcessingFilterEntryPoint"
class="org.springframework.security.ui.cas.CasProcessingFilterEntryPoint">
<property name="loginUrl" value="https://obll1973.abc.com:8443/cas/login"/>
<property name="serviceProperties" ref="serviceProperties"/>
</bean>
<!--
Handles the CAS ticket processing.
-->
<bean id="casAuthenticationProvider"
class="org.springframework.security.providers.cas.CasAuthenticationProvider">
<security:custom-authentication-provider />
<property name="userDetailsService" ref="customUserDetailsService" />
<property name="serviceProperties" ref="serviceProperties" />
<property name="ticketValidator">
<bean class="org.jasig.cas.client.validation.Cas20ServiceTicketValidator">
<constructor-arg index="0" value="https://obll1973.abc.com:8443/cas" />
</bean>
</property>
<property name="key" value="an_id_for_this_auth_provider_only"/>
</bean>
<!--
To access request.getRemoteUser() from client application
-->
<bean id="wrappingFilter" class="org.jasig.cas.client.util.HttpServletRequestWrapperFilter" />
</beans>
我面临的问题是以下异常:
java.lang.RuntimeException: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
org.jasig.cas.client.util.CommonUtils.getResponseFromServer(CommonUtils.java:341)
org.jasig.cas.client.util.CommonUtils.getResponseFromServer(CommonUtils.java:305)
org.jasig.cas.client.validation.AbstractCasProtocolUrlBasedTicketValidator.retrieveResponseFromServer(AbstractCasProtocolUrlBasedTicketValidator.java:50)
org.jasig.cas.client.validation.AbstractUrlBasedTicketValidator.validate(AbstractUrlBasedTicketValidator.java:207)
org.springframework.security.providers.cas.CasAuthenticationProvider.authenticateNow(CasAuthenticationProvider.java:145)
org.springframework.security.providers.cas.CasAuthenticationProvider.authenticate(CasAuthenticationProvider.java:131)
org.springframework.security.providers.ProviderManager.doAuthentication(ProviderManager.java:188)
org.springframework.security.AbstractAuthenticationManager.authenticate(AbstractAuthenticationManager.java:46)
org.springframework.security.ui.cas.CasProcessingFilter.attemptAuthentication(CasProcessingFilter.java:94)
org.springframework.security.ui.AbstractProcessingFilter.doFilterHttp(AbstractProcessingFilter.java:258)
org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
org.springframework.security.ui.logout.LogoutFilter.doFilterHttp(LogoutFilter.java:89)
org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
org.springframework.security.context.HttpSessionContextIntegrationFilter.doFilterHttp(HttpSessionContextIntegrationFilter.java:235)
org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
org.springframework.security.util.FilterChainProxy.doFilter(FilterChainProxy.java:175)
org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:236)
org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)
复制上述异常的步骤:1) 我尝试使用 https://obll1973.abc.com:8663/myWebApp/protected/ 访问 myWebApp2) 它被重定向到 cas 服务器,即 https://obll1973.abc.com:8443/cas/login并在提供用户名/密码后在这里,一旦 myWebApp 再次向 cas 服务器发送请求以验证生成的 token ,就会捕获异常。
我们将不胜感激任何建议/帮助。
最佳答案
您的 Spring-CAS 配置看起来不错。
SSLHandshakeException 出现的唯一原因是将 SSL key 不正确地导入到创建的 keystore 或 JVM keystore 中。
注意:CN 的别名(这里是 cas)应该与机器的主机名相同。
要查找机器的主机名,在控制台或命令提示符中只需键入不带引号的“主机名”。
在根目录下创建一个名为app的目录
[root@localhost app]# keytool -genkey -alias cas -keyalg RSA -keystore .cas -storepass caspasswd
What is your first and last name? [Unknown]: cas What is the name of your organizational unit? [Unknown]: MYCOMPANY What is the name of your organization? [Unknown]: MYCOMPANY What is the name of your City or Locality? [Unknown]: Bangalore What is the name of your State or Province? [Unknown]: Karnataka What is the two-letter country code for this unit? [Unknown]: IN Is CN=cas, OU=MYCOMPANY, O=MYCOMPANY, L=Bangalore, ST=Karnataka, C=IN correct? [no]: yes
Enter key password for (give the password mentioned above -- i.e caspasswd in this case) (RETURN if same as keystore password): Re-enter new password:
[root@localhost app]# keytool -exportcert -alias cas -file cas.crt -keystore .cas Enter keystore password: Certificate stored in file
[root@localhost app]# ls cas.crt softwares test.class test.java tomcat7027CAS
[root@localhost app]# keytool -import -alias cas -file cas.crt -keystore /app/softwares/jdk1.6.0_27/jre/lib/security/cacerts Enter keystore password: Owner: CN=cas, OU=MYCOMPANY, O=MYCOMPANY, L=Bangalore, ST=Karnataka, C=IN Issuer: CN=cas, OU=MYCOMPANY, O=MYCOMPANY, L=Bangalore, ST=Karnataka, C=IN Serial number: 510a6a63 Valid from: Thu Jan 31 18:28:11 IST 2013 until: Wed May 01 18:28:11 IST 2013 Certificate fingerprints: MD5: 52:8E:2E:74:C6:57:CD:B3:B0:B6:6C:17:D9:0D:77:F3 SHA1: 1F:AA:4C:22:B9:16:DC:AA:D4:87:07:CF:DD:B2:11:A6:AE:36:9A:DB Signature algorithm name: SHA1withRSA Version: 3 Trust this certificate? [no]: yes Certificate was added to keystore
[root@localhost app]# keytool -list -keystore /app/softwares/jdk1.6.0_27/jre/lib/security/cacerts -alias cas Enter keystore password: cas, Jan 31, 2013, trustedCertEntry, Certificate fingerprint (MD5): 52:8E:2E:74:C6:57:CD:B3:B0:B6:6C:17:D9:0D:77:F3
[root@localhost app]#
在您的 tomcat server.xml 中,您还可以使用 https 连接器,如下所示
<Connector port="8443" protocol="org.apache.coyote.http11.Http11Protocol" SSLEnabled="true"
maxThreads="150" scheme="https" keystoreFile="/app/.cas" keystorePass="mykeypassword"
secure="true" connectionTimeout="240000"
clientAuth="false" sslProtocol="TLS" allowUnsafeLegacyRenegotiation="true" />
<!-- Define an AJP 1.3 Connector on port 8009 -->
<Connector port="8069" protocol="AJP/1.3" redirectPort="8443" />
以上 key 用于 CAS 服务器。您可以为应用程序创建自己的单独 key 。
但是两个 key 都应该导入到 JVM cacerts keystore (如何:在下面提到)
现在是最重要的部分:假设您的 CAS 服务器别名是 cas
你的应用服务器别名是myapp
在两台服务器中同时保留 key cas.crt 和 myapp.crt 以导入 JVM
在两个服务器中执行以下操作:
1) keytool -import -alias cas -file /app/cas.crt -keystore /usr/java/jdk1.5.0_22/jre/lib/security/cacerts
2) keytool -import -alias myapp -file /app/cas.crt -keystore /usr/java/jdk1.5.0_22/jre/lib/security/cacerts
要验证使用以下命令 --
1) keytool -list -v -keystore /usr/java/jdk1.5.0_22/jre/lib/security/cacerts -alias cas
2) keytool -list -v -keystore /usr/java/jdk1.5.0_22/jre/lib/security/cacerts -alias myapp
如果使用多个版本的 java,请确保 Java--JRE--LIB--SECURITY--CACERTS 文件
这将消除您的错误。
注意:
如果在提供正确的用户凭据后浏览器显示空白页面,修改系统的host文件(linux为/etc/hosts,windows为c:\windows\system32\driver\etc\hosts)
在那里添加cas服务器ip
例如。
162.25.250.60 我的应用程序162.25.250.81 ca
任何疑问都可以澄清。
您可以引用以下内容:
https://wiki.jasig.org/display/CASUM/SSL+Troubleshooting+and+Reference+Guide
关于ssl - CAS + SSLHandshakeException + ValidatorException + PKIX 路径构建失败 + 无法找到请求目标的有效证书路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13123083/
我收到以下错误。我将发布我正在做的代码明智的事情,然后将发布堆栈跟踪,我一直在努力寻找足够的信息来修复。我正在使用自签名证书。 SSLContext sslContext = null;
我拿了以下BalusC kickoff example并通过添加提交按钮和其他 h:messages 并删除 f:ajax 对其进行了修改。来自 h:inputSecret's (由于某种原因删除了
从星期一开始,我面临与sun.security.ValidatorException相关的问题。在上周一之前,一切正常。 异常(exception)是: 配置根项目“CoreApp”时发生问题。 Co
当我使用 Primefaces Maven 存储库时出现以下异常 mvn clean spring-boot:run [ERROR] Failed to execute goal on project
我正在尝试在 Ubuntu 16.04 上使用 sbt,但是在尝试运行它时出现错误。我进行了全新安装,然后完全按照 the sbt site 中的说明进行操作。 ,但是当我做 sbt 时得到以下信息:
我正在使用gradle构建springboot项目,但是gradle负载依赖性始终不好。错误如下: FAILURE: Build failed with an exception. * What we
我正在使用 REST Assured,但是当我尝试发送请求时,出现以下错误:- javax.net.ssl.SSLHandshakeException:sun.security.validator.V
我有一个用 Java 编写的 RESTful 客户端,用于使用 SSL 的 Web 服务。该应用程序已经运行了几个星期。突然之间,所有与 Web 服务进行交易的尝试都会导致以下异常: sun.secu
我目前代表一位正在度假的同事。他负责的一个应用这几天一直报如下错误。 Error: IOException sun.security.validator.ValidatorException: PKI
我正在研究中央认证系统 (jasig.org) 以实现单点登录功能对于我的 Intranet Web 应用程序。我有两个 tomcat 实例在我的同一台机器(windows)上运行。两个 tomcat
为了对我的 xmpp 堆栈进行集成测试,我在本地主机上设置了一个 vysper 服务器 (0.7)。现在我想使用版本 4.0.2 中的 smack-core 和 smack-tcp 连接到服务器。 问
我低于异常 sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.ce
以前,我可以成功地向 Web 服务发送请求并接收响应,但它现在返回以下异常。根据其他答案,我需要更新证书,但我需要知道为什么我现在收到此异常。另一个问题是,我可以找到我的 java_home 的地址,
创建了一台 Azure SQL Server 计算机,我能够进行 rdp 并通过本地 SQL Server Mgt Studio 客户端进行连接。 但是,我无法使用下面的连接字符串通过 Java 代码
DataGrip 无法连接到我的 Postgres 实例,但我可以通过终端上的 psql 正常连接: psql -h dbhost.com reps username >Password for us
我已经使用此命令创建了 CSR 请求: openssl req -out certificatecsr.csr -new -newkey rsa:2048 -keyout certificatekey
我们所处的场景是,公司代理正在解密所有 HTTPS 流量,并使用 Java 不信任的 CA ROOT 对其进行重新签名。 我们还面临无法修改 Java 目录中的 cacerts 文件的情况。 我们在许
org.apache.axis2.AxisFault:sun.security.validator.ValidatorException:PKIX 路径构建失败:sun.security.provid
我在服务器上安装了 apache、Tomcat7,我的请求从 apache 重定向到 tomcat。我在 apache 上安装了 SSL。我在我的应用程序中使用 goole api 进行一些身份验证。
我的公司运行一个用 ColdFusion MX7.0.2 构建的旧应用程序,运行 Java 1.4.2。我无法升级 ColdFusion,因为 CyberSource 不支持任何高于 MX7 的版
我是一名优秀的程序员,十分优秀!