private SSLEngine getClientEngine() throws Exception {
		// Create/initialize the SSLContext with key material
		char[] passphrase = password.toCharArray();
		// First initialize the key and trust material.
		KeyStore ks = KeyStore.getInstance("JKS");
		ks.load(new FileInputStream(clientKeystore), passphrase);
		SSLContext sslContext = SSLContext.getInstance("TLS");
		
		//****************Client side specific*********************
		// TrustManager's decide whether to allow connections.
		TrustManagerFactory tmf = TrustManagerFactory.getInstance("SunX509");
		tmf.init(ks);
		sslContext.init(null, tmf.getTrustManagers(), null);		
		//****************Client side specific*********************
		
		SSLEngine engine = sslContext.createSSLEngine();
		engine.setUseClientMode(true);
		SSLEngine client = engine;	
		return client;
	}
	
//	private void putString(ByteBuffer b, String fullString) {
//		if(b == null)
//			throw new IllegalArgumentException("Cannot pass in a null buffer");
//		else if(fullString == null)
//			throw new IllegalArgumentException("Cannot pass in a null string");
//		byte[] encodedString;
//		try {
//			ByteArrayOutputStream out = new ByteArrayOutputStream();
//			OutputStreamWriter writer = new OutputStreamWriter(out);
//			writer.write(fullString);
//			writer.flush();
//			encodedString = out.toByteArray();
//		} catch(IOException e) {
//			throw new RuntimeException("Should never happen", e);
//		}
//
//		b.put(encodedString);	
//	}