1

I want to get session for Alfresco 4.2.1 Repository. But i am not getting below Exception

Exception in thread "main" org.apache.chemistry.opencmis.commons.exceptions.CmisConnectionException: Cannot access "https://test.uk.corplan.net/alfresco/api/-default-/public/cmis/versions/1.1/atom": handshake alert:  unrecognized_name
at org.apache.chemistry.opencmis.client.bindings.spi.http.DefaultHttpInvoker.invoke(DefaultHttpInvoker.java:228)
at org.apache.chemistry.opencmis.client.bindings.spi.http.DefaultHttpInvoker.invokeGET(DefaultHttpInvoker.java:55)
at org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtomPubService.read(AbstractAtomPubService.java:615)
at org.apache.chemistry.opencmis.client.bindings.spi.atompub.AbstractAtomPubService.getRepositoriesInternal(AbstractAtomPubService.java:782)
at org.apache.chemistry.opencmis.client.bindings.spi.atompub.RepositoryServiceImpl.getRepositoryInfos(RepositoryServiceImpl.java:65)
at org.apache.chemistry.opencmis.client.bindings.impl.RepositoryServiceImpl.getRepositoryInfos(RepositoryServiceImpl.java:88)
at org.apache.chemistry.opencmis.client.runtime.SessionFactoryImpl.getRepositories(SessionFactoryImpl.java:133)
at org.apache.chemistry.opencmis.client.runtime.SessionFactoryImpl.getRepositories(SessionFactoryImpl.java:111)
at com.rave.utils.GetAlfrescoSession.getalfrescosession(GetAlfrescoSession.java:42)
at com.rave.utils.GetAlfrescoSession.main(GetAlfrescoSession.java:18)Caused by: javax.net.ssl.SSLProtocolException: handshake alert:  unrecognized_name
at sun.security.ssl.ClientHandshaker.handshakeAlert(Unknown Source)
at sun.security.ssl.SSLSocketImpl.recvAlert(Unknown Source)
at sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source)
at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
at sun.net.www.protocol.https.HttpsClient.afterConnect(Unknown Source)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(Unknown Source)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.connect(Unknown Source)
at org.apache.chemistry.opencmis.client.bindings.spi.http.DefaultHttpInvoker.invoke(DefaultHttpInvoker.java:203)

I have written below code to get the session. but i am not getting whats wrong here.

import java.util.HashMap;
import java.util.Map;
import org.apache.chemistry.opencmis.client.api.Session;
import org.apache.chemistry.opencmis.client.api.SessionFactory;
import org.apache.chemistry.opencmis.client.runtime.SessionFactoryImpl;
import org.apache.chemistry.opencmis.commons.SessionParameter;
import org.apache.chemistry.opencmis.commons.enums.BindingType;

public class GetAlfrescoSession {
    public static void main(String[] args) {
        getalfrescosession();
    }

    public static Session getalfrescosession() {
        Map<String, String> parameter = new HashMap<String, String>();
        parameter.put(SessionParameter.USER, "admin");
        parameter.put(SessionParameter.PASSWORD, "admin");
        parameter.put(SessionParameter.ATOMPUB_URL,
                "https://test.uk.corplan.net/alfresco/api/-default-/public/cmis/versions/1.1/atom");
        parameter.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value());
        parameter.put(SessionParameter.OBJECT_FACTORY_CLASS, "org.alfresco.cmis.client.impl.AlfrescoObjectFactoryImpl");
        SessionFactory factory = SessionFactoryImpl.newInstance();
        Session session = factory.getRepositories(parameter).get(0).createSession();
        return session;
    }
}

Can anyone please help me?

Thanks in Advance...

Deepak Talape
  • 997
  • 1
  • 9
  • 35
  • Did you see my post [How to connect to Alfresco repository](http://stackoverflow.com/questions/38407839/how-to-make-a-link-between-a-jsp-page-and-an-alfresco-activiti/38455289#38455289) i am almost sure you have an error in your `ATOMPUB_URL` – Yagami Light Apr 17 '17 at 06:16
  • Please use this `"http://127.0.0.1:8080/alfresco/api/-default-/public/cmis/versions/1.0/atom"` for your `ATOMPUB_URL` and tell me if it does work – Yagami Light Apr 17 '17 at 06:18
  • @YagamiLight This happends only in the case of production server. With same URL i am able to connect to LOCAL and DEV server. But i am getting issue while connecting to PRODUCTION. – Deepak Talape Apr 17 '17 at 09:13
  • is it the same version between local and production ?!? – Yagami Light Apr 17 '17 at 09:15
  • Yes, with same version means alfresco 4.2.1 i am able to connect to repository on local, but on production i am getting some SSL related Error.. – Deepak Talape Apr 17 '17 at 09:21
  • try to disable the firewall of the production and see – Yagami Light Apr 17 '17 at 09:22

4 Answers4

4

I believe that the URL that you use is compatible only with Alfresco 5.x. If you use Alfresco 4.2.x, you need to use an other URL. Just open the page:

http://<your alfresco>/alfresco/s/cmis/index

And you should get all details related to your instance. The URL of the CMIS repo should be:

http://<your alfresco>/alfresco/cmisatom
4

This has nothing to do with Alfresco or OpenCMIS. SSL is no set up correctly on the server.

See this answer: SSL handshake alert: unrecognized_name error since upgrade to Java 1.7.0

Florian Müller
  • 3,215
  • 1
  • 14
  • 11
  • Muller i aulredy gone through the link you provided. But i am not getting what exactly i have to do. Can you please tell me some simple steps to follow regarding SSL setup. That will be really help full. Thanks in Advance.... – Deepak Talape Apr 16 '17 at 08:15
  • 1
    Try adding this before you create the session: `System.setProperty("jsse.enableSNIExtension", "false");` – Florian Müller Apr 16 '17 at 08:39
  • Not its giving additional error as follows.... javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target – Deepak Talape Apr 16 '17 at 09:41
  • The server is probably providing a self-signed certificate. The server admin has to fix the SSL configuration. – Florian Müller Apr 16 '17 at 09:54
  • Where exactly it has to fix SSL configuration? Can you please elaborate? – Deepak Talape Apr 16 '17 at 10:44
1

I just installed the latest Alfresco 4.2.x and I checked the URL:

http://127.0.0.1:8080/alfresco/s/cmis/index

Then, I clicked on the link highlighted in the screenshot called AtomPub Service Document and the URL of the CMIS service is:

http://127.0.0.1:8080/alfresco/cmisatom

Be aware that Alfresco 4.2 supports only CMIS 1.0 and not CMIS 1.1.

enter image description here

  • Even i am also able to access or connect to Alfresco repository on my local machine. but this issue is there with PRODUCTION. I am not able ti connect to production only. and the exception i am getting is related to SSL – Deepak Talape Apr 17 '17 at 10:10
0

I've run into this issue before on version 5.1 and what fixed it for me was the following setup:

            SessionFactory factory = SessionFactoryImpl.newInstance();
            Map<String, String> parameters = new HashMap<String, String>();

            // user credentials
            parameters.put(SessionParameter.USER, "username");
            parameters.put(SessionParameter.PASSWORD, "password");

            // connection settings
            parameters.put(SessionParameter.ATOMPUB_URL, "https://someurl.com/alfresco/cmisatom");
            parameters.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value());
            parameters.put(SessionParameter.REPOSITORY_ID, "IMPORTANT! the repository id must be defined here");

            // create session
            Session session = factory.createSession(parameters);

If you're using version 4.2 you need to verify that you connection endpoints and the version of CMIS you're using are are compatible.

Emir Memic
  • 270
  • 1
  • 3
  • 14