繁体   English   中英

将 SAP Cloud Platform 连接到 Office 365 API 时对等方未通过身份验证的异常

[英]Peer not authenticated exception when connecting SAP Cloud Platform to Office 365 API

我正在实施 SAP Cloud Platform Java 应用程序以使用 OAuth2 身份验证连接到 Office 365 API ( https://outlook.office.com/ )。 当我在 Apache Tomcat 本地服务器上运行它时,我正确地从服务器获得了响应。 当我在 SAP Cloud Platform 上运行相同的代码时,我得到 javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated| 在这两种情况下,我都得到了正确的 OAuth 令牌。 我在这里缺少什么? 我正在使用的代码是:

private Object getResponseFromAzure(String url, String methodType) {
    AuthenticationResult result = null;
    try {
        result = getAccessTokenFromUserCredentials(); // OAuth2 bearer token
    } catch (Exception e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }
    String accessToken = result.getAccessToken();
    System.out.println("Access Token is - " + accessToken);
    HttpClient client = new DefaultHttpClient();

    HttpRequestBase request = null;
    if ("GET".equals(methodType)) {
        request = new HttpGet(url);
    } else if ("POST".equals(methodType)) {
        request = new HttpPost(url);
    }

    request.addHeader("Authorization", "Bearer " + accessToken);
    HttpResponse response = null;
    try {
        response = client.execute(request);
    } catch (ClientProtocolException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

在 SCP 中创建一个目的地。 在目标服务中上传根证书和中间证书。 这是用户界面的一部分。

使用目标而不是直接连接从 Java 应用程序进行连接。 示例代码位于https://help.sap.com/viewer/cca91383641e40ffbe03bdc78f00f681/Cloud/en-US/e592cf6cbb57101495d3c28507d20f1b.html

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM