cmd: improve error detection on client

Now it detects invalid certificates sent by the server.

Now we can close #178.