Home > Enterprise >  Sharepoint SSL certification, use REST API access, can you skip?
Sharepoint SSL certification, use REST API access, can you skip?

Time:09-19

Now in the JAVA HTTPCLIENT, access to the sharepoint site rest API interface, but the site is https://XXX,
Whether have enough permissions to the user, password, SSL certificate is needed?
Tried a lot of methods, returns are Access denied.
Nasty, consult

CodePudding user response:

Can skip the SSL certificate authentication this step?

CodePudding user response:

The String url="https://site/_api/web/title";
Map ParamHeader=new HashMap<> (a);
ParamHeader. Put (" Accept ", "application/XML");
Map ParamBody=new HashMap<> (a);
ParamBody. Put (" client_id ", "test");
ParamBody. Put (" client_secret ", "ttest");
//the String result=HTTPSClientUtil. DoGet (httpClient, url, paramHeader, paramBody);

The String result=HTTPSClientUtil. DoGet (httpClient, url, null, null);
System. The out. Println (" @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ @ ");
System.out.println(result);

CodePudding user response:

Public void prepareCertificate () throws the Exception {
System. The out. Println (" # # # # # # # # # # # # # # # # # # # # # # # # ");
//skip certificate validation
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;
}
};
//set to have the trust certificate
CTX. Init (null, new TrustManager []} {tm, null);
Enclosing connectionSocketFactory=new SSLConnectionSocketFactory (CTX);
}

CodePudding user response:

You it's not a question of certificate, client access rest API, need take authorized to visit, with authorization method in asp.net, don't know whether Java has a similar method;
Give you an example of a net consult, you try to translate into Java
 Uri Uri=new Uri (siteURL + "/_api/web/"); 
NetworkCredential nc=new NetworkCredential (" admin ", "pass - 1234", "domain");
HttpWebRequest request=(HttpWebRequest) WebRequest. Create (uri);
Request. The Method="GET";
Request. Credentials=nc;
HttpWebResponse response=(HttpWebResponse) request. The method GetResponse ();
Stream, Stream=response. GetResponseStream ();

CodePudding user response:

Java inside also is to have the authorization
  • Related