Thanks Andy,

thank you for your reply. I've made it! With 3.1.1, this code works for me:

CredentialsProvider credsProvider = new BasicCredentialsProvider (); Credentials credentials = new UsernamePasswordCredentials ( USER, PWD );
            credsProvider.setCredentials ( AuthScope.ANY, credentials );

            SSLContext sslcontext =
                SSLContexts
                .custom ()
                .loadTrustMaterial (
                    null,
                    new TrustStrategy ()
                    {
public boolean isTrusted ( X509Certificate[] chain, String authType ) throws CertificateException {
                            return true;
                        }
                    })
                .build();

SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory (
                sslcontext, null, null, new NoopHostnameVerifier ()
            );

            HttpClient httpClient = HttpClients
                    .custom()
                    .setSSLSocketFactory ( sslsf )
              .setDefaultCredentialsProvider ( credsProvider )
              .build();

            QueryExecution qx = QueryExecutionFactory.sparqlService (
                "https://dev.lacunaclientscope.com/sparql/";,
                sparql,
                httpClient
            );
That comes from your SO link, but I had to define a more liberal TrustStrategy, which trusts anything, TrustSelfSignedStrategy causes the same error as before.

Marco


On 13/01/2017 09:25, Andy Seaborne wrote:
In Jena 3.1.1, the way security is handled changed.

Now, the application creates the appropriate Apache HttpClient and that is used for the remote service access.

http://jena.apache.org/documentation/query/http-auth.html

see also:

http://stackoverflow.com/questions/30250102/any-apache-httpclient-4-4-example-for-trust-self-signed-certificates

Andy

Reply via email to