sharepoint的SSL认证,用REST API访问的话,能跳过吗?

zgld 2018-05-23 04:05:01
现在用JAVA的HTTPCLIENT ,访问sharepoint站点的rest api接口。但是站点是https://XXX的。
有足够权限的user,password,是否还需要SSL证书呢?
试了好多方法,返回都是Access denied.
急,求教
...全文
1016 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
jerysab 2018-10-16
  • 打赏
  • 举报
回复
java里边也是有授权认证的
霖雨 版主 2018-05-24
  • 打赏
  • 举报
回复
你这不是证书的问题,客户端访问rest api,需要带授权去访问,asp.net中有授权的方法,不知道java是不是也有类似的方法;
给你一个net的例子参考一下,你试试翻译成java吧
Uri uri = new Uri(siteURL + "/_api/web/");
NetworkCredential nc = new NetworkCredential("admin", "pass-1234", "domain");
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
request.Method = "GET";
request.Credentials = nc;
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream stream = response.GetResponseStream();
zgld 2018-05-23
  • 打赏
  • 举报
回复
public void prepareCertificate() throws Exception { System.out.println("########################"); // 跳过证书验证 SSLContext ctx = SSLContext.getInstance("SSL"); X509TrustManager tm = new X509TrustManager() { @Override public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException { } @Override public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException { } @Override public X509Certificate[] getAcceptedIssuers() { return null; } }; // 设置成已信任的证书 ctx.init(null, new TrustManager[] { tm }, null); this.connectionSocketFactory = new SSLConnectionSocketFactory(ctx); }
zgld 2018-05-23
  • 打赏
  • 举报
回复
String url = "https://site/_api/web/title"; Map<String, String> paramHeader = new HashMap<>(); paramHeader.put("Accept", "application/xml"); Map<String, String> paramBody = new HashMap<>(); paramBody.put("client_id", "test"); paramBody.put("client_secret", "ttest"); //String result = HTTPSClientUtil.doGet(httpClient, url, paramHeader, paramBody); String result = HTTPSClientUtil.doGet(httpClient, url, null, null); System.out.println("@@@@@@@@@@@@@@@@@@@@@@@"); System.out.println(result);
zgld 2018-05-23
  • 打赏
  • 举报
回复
能否跳过ssl证书认证这一步?

3,241

社区成员

发帖
与我相关
我的任务
社区描述
企业开发 SharePoint
社区管理员
  • SharePoint社区
  • 霖雨
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧