Pokazywanie postów oznaczonych etykietą Errors. Pokaż wszystkie posty
Pokazywanie postów oznaczonych etykietą Errors. Pokaż wszystkie posty

piątek, 12 stycznia 2018

HttpClient - ssl - unable to find valid certification path to requested target

The 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 usually stands for issues with accepting/validating SSL/TLS certificate given by web server. ClientHandshaker class is responsible for handshaking from the client side. It shares common logic such control flow and key generation with its counterpart ServerHandshaker though common parent class called Handshaker.
void processMessage(byte type, int messageLen) throws IOException {
 ...
 switch (type) {
 ...
 case HandshakeMessage.ht_certificate:
       if (keyExchange == K_DH_ANON || keyExchange == K_ECDH_ANON
                    || keyExchange == K_KRB5 || keyExchange == K_KRB5_EXPORT) {
                fatalSE(Alerts.alert_unexpected_message,
                    "unexpected server cert chain");
                // NOTREACHED
            }
            this.serverCertificate(new CertificateMsg(input));
            serverKey =
                session.getPeerCertificates()[0].getPublicKey();
            break;
Let's go briefly to the details 1. Creating CerificateMsg just takes input as a HandshakeInStream, reads first 24 bytes as a chainLenght, so can read the cert as a byte array and finally instantiates X.509 certificate, as below
cf = CertificateFactory.getInstance("X.509");
cf.generateCertificate(new ByteArrayInputStream(cert)
2. serverCertificate method will deletegate cerificate validation to the Trust Manager taken from sslContext. To solve the error the sslcontext have to be feeded with TrustStrategy that accepts self-sighed cerificates as trusted. Apache Http Client comes with org.apache.http.conn.ssl.TrustSelfSignedStrategy to do so.
HttpClients.custom()
                .setSSLSocketFactory(new SSLConnectionSocketFactory(SSLContextBuilder.create()
      .loadTrustMaterial(TrustSelfSignedStrategy.INSTANCE)
      .build(), NoopHostnameVerifier.INSTANCE))
                .build();

wtorek, 13 stycznia 2015

Rsync - ERROR: rsync error: protocol incompatibility (code 2) at compat.c(171) [sender=3.0.6]

$rsync -av file.zip user@host:file.zip
protocol version mismatch -- is your shell clean?
(see the rsync man page for an explanation)
rsync error: protocol incompatibility (code 2) at compat.c(171) [sender=3.0.6]
This message can be somewhat misleading at first glance, but the key to solve this issue is answering what actually means "clean shell" ;). Most probably there is some MOTD (message of the day) displayed in one of the config files (eg. .bashrc) when user starts a new session. To check if it is the case, try the following command:

ssh designer@10.1.1.162 true | wc -c
If this command returns more then 0 that means there is some output produced. Get rid of it should fix it.

piątek, 2 kwietnia 2010

Eclipse - Workspace Cannot Be Locked (former: Workspace in use or cannot be created)

Full error message:
Could not launch the application because the associated workspace is currently use by another Eclipse application.

Basically the following should do the job:
rm $WORKSPACE_DIR/.metadata/.lock

Quick explanation:
Each time you run Eclipse with particular workspace it is locked. Mechanism of that is quite simple. It is just a .lock file in .metadata directory. Thus the only one need to do in order to unlock workspace is to delete .lock file. Usually such happens when Eclipse hangs and you need restart your machine.