public void getCredential() throws IOException, GeneralSecurityException {
		LOG.debug("Generating MyProxyLogon object..");
		MyProxyLogon myProxyLogon = getConnection();

		LOG.debug("Retrieving credentials from the MyProxy server..");
		try{
			myProxyLogon.getCredentials();
		}catch(SSLHandshakeException e){
			//Avoid "CN doesn't match server name" issue: the OpenID indicates 
			//that the MyProxy authentication service is located at some host and
			//port (usually 7512), but then, this host and port, in some cases, 
			//have a certificate with a subject that does not match the server host
			//name (and without any alternative subject name). 
			//Therefore, the SSL connection fails.
			LOG.warn(e.getMessage());

			//Replace host for its canonical host name
			InetAddress inetAddress=InetAddress.getByName(myProxyLogon.getHost());
			myProxyLogon.setHost(inetAddress.getCanonicalHostName());
			myProxyLogon.getCredentials();
		}
		LOG.info("done!");

		if (this.trustRoots) {
			try {
				LOG.info("Writing trust roots to " + this.caDirectory);
				myProxyLogon.writeTrustRoots(this.caDirectory);
				LOG.debug("Retrieved trust roots writed in " + this.caDirectory);
			} catch (IOException e) {
				LOG.error("Couldn't write certificates");
				System.exit(1);
			}
		}

		this.x509Certificates = this.myProxyLogon.getCertificates();
		LOG.debug("X509Certificates:\n "
				+ this.x509Certificates);
		
		this.privateKey = myProxyLogon.getPrivateKey();
		LOG.debug("PrivateKey:" + this.privateKey.toString());
	}