30
“ PKIX路径构建失败”和“无法找到到所请求目标的有效认证路径”
我正在尝试为我的Java项目使用twitter4j库获取推文。在我的第一次跑步中,我得到了关于证书sun.security.validator.ValidatorException和的错误sun.security.provider.certpath.SunCertPathBuilderException。然后我通过以下方式添加了Twitter证书: C:\Program Files\Java\jdk1.7.0_45\jre\lib\security>keytool -importcert -trustcacerts -file PathToCert -alias ca_alias -keystore "C:\Program Files\Java\jdk1.7.0_45\jre\lib\security\cacerts" 但是没有成功。这是获取推文的过程: public static void main(String[] args) throws TwitterException { ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setDebugEnabled(true) .setOAuthConsumerKey("myConsumerKey") .setOAuthConsumerSecret("myConsumerSecret") .setOAuthAccessToken("myAccessToken") .setOAuthAccessTokenSecret("myAccessTokenSecret"); TwitterFactory tf = new TwitterFactory(cb.build()); Twitter twitter = tf.getInstance(); try { Query query = new Query("iphone"); QueryResult result; result …