0

我从https://github.com/box/box-java-sdk-v2下载了最新的 Box Java SDK,并按照自述文件中的说明运行示例 HelloWorld 程序。我在程序中更新了我的客户端 ID 和密钥并执行了“ant run”。浏览器窗口打开,我可以使用我的凭据进行身份验证。重定向 URL 设置为:

http://localhost:4000 

将代码传递到重定向 URL 后,我得到以下异常。到此为止,确认我的客户端 ID、密钥和重定向 URL 都在 Box 应用程序中正确配置。

我不明白 SSL 错误是从哪里出现的,因为我的重定向 URL 中没有 https。我在我的 Mac (Mavericks 10.9.4) 上运行它。

java -version

java version "1.7.0_60"
Java(TM) SE Runtime Environment (build 1.7.0_60-b19)
Java HotSpot(TM) 64-Bit Server VM (build 24.60-b09, mixed mode)

这是异常消息:

run:
 [java] GET /?state=&code=JeIYUCFq9meQFeRCNJZy2GbLzc2KOqaA HTTP/1.1
 [java] com.box.restclientv2.exceptions.BoxRestException
 [java]     at org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava.java:194)
 [java]     at org.apache.tools.ant.taskdefs.Java.run(Java.java:771)
 [java]     at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:221)
 [java]     at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:135)
 [java]     at org.apache.tools.ant.taskdefs.Java.execute(Java.java:108)
 [java]     at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
 [java]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 [java]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
 [java]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 [java]     at java.lang.reflect.Method.invoke(Method.java:606)
 [java]     at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
 [java]     at org.apache.tools.ant.Task.perform(Task.java:348)
 [java]     at org.apache.tools.ant.Target.execute(Target.java:435)
 [java]     at org.apache.tools.ant.Target.performTasks(Target.java:456)
 [java]     at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1393)
 [java]     at org.apache.tools.ant.Project.executeTarget(Project.java:1364)
 [java]     at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
 [java]     at org.apache.tools.ant.Project.executeTargets(Project.java:1248)
 [java]     at org.apache.tools.ant.Main.runBuild(Main.java:851)
 [java]     at org.apache.tools.ant.Main.startAnt(Main.java:235)
 [java]     at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
 [java]     at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)
 [java] Caused by: com.box.restclientv2.exceptions.BoxRestException
 [java]     at com.box.boxjavalibv2.BoxRESTClient.handleException(BoxRESTClient.java:183)
 [java]     at com.box.boxjavalibv2.BoxRESTClient.execute(BoxRESTClient.java:118)
 [java]     at com.box.boxjavalibv2.BoxRESTClient.execute(BoxRESTClient.java:72)
 [java]     at com.box.boxjavalibv2.resourcemanagers.AbstractBoxResourceManager.getResponseAndParse(AbstractBoxResourceManager.java:118)
 [java]     at com.box.boxjavalibv2.resourcemanagers.AbstractBoxResourceManager.getResponseAndParseAndTryCast(AbstractBoxResourceManager.java:108)
 [java]     at com.box.boxjavalibv2.resourcemanagers.BoxOAuthManagerImpl.createOAuth(BoxOAuthManagerImpl.java:81)
 [java]     at com.box.boxjavalibv2.resourcemanagers.BoxOAuthManagerImpl.createOAuth(BoxOAuthManagerImpl.java:53)
 [java]     at HelloWorld.getAuthenticatedClient(HelloWorld.java:57)
 [java]     at HelloWorld.main(HelloWorld.java:39)
 [java]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 [java]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
 [java]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 [java]     at java.lang.reflect.Method.invoke(Method.java:606)
 [java]     at org.apache.tools.ant.taskdefs.ExecuteJava.run(ExecuteJava.java:217)
 [java]     at org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava.java:152)
 [java]     ... 21 more
 [java] Caused by: javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated
 [java]     at sun.security.ssl.SSLSessionImpl.getPeerCertificates(SSLSessionImpl.java:397)
 [java]     at org.apache.http.conn.ssl.AbstractVerifier.verify(AbstractVerifier.java:126)
 [java]     at org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFactory.java:437)
 [java]     at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:180)
 [java]     at org.apache.http.impl.conn.ManagedClientConnectionImpl.open(ManagedClientConnectionImpl.java:294)
 [java]     at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:643)
 [java]     at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:479)
 [java]     at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:906)
 [java]     at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:805)
 [java]     at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:784)
 [java]     at com.box.boxjavalibv2.BoxRESTClient.getResponse(BoxRESTClient.java:148)
 [java]     at com.box.boxjavalibv2.BoxRESTClient.execute(BoxRESTClient.java:98)
 [java]     ... 34 more
 [java] Java Result: -1

如果我应该尝试不同的东西,请告诉我。

谢谢!

4

1 回答 1

0

SSL 错误是因为我的机器上名为 Netskope 客户端的应用程序拦截了所有流量。一旦我禁用它,一切都开始正常工作。

于 2014-07-17T00:00:02.600 回答