Code example for SSLSocket

Methods: setEnableSessionCreationsetUseClientModestartHandshake

0
				m_sslSocket = createSSLSocket(i_aCtx);
			} catch(GTBSSLSocketException e)
			{ 
				throw e;
			} 
				m_sslSocket.startHandshake();
				successfullyEstablishedConn = true;
				/* Resume sessions from now on */ 
				m_sslSocket.setEnableSessionCreation(false);
		} catch (IOException e)
		{ 
			successfullyEstablishedConn = false;
			Log.w(TAG, "Rehandshake Failure");
		} 
	} 
	 
	/** 
	 * Closes the current connection to the server and returns a new instance 
	 *   of GtBSLLSocketFactoryWrapper. 
	 * @param i_aCtx 
	 * @return 
	 * @throws UnrecoverableKeyException 
	 * @throws KeyStoreException 
	 * @throws NoSuchAlgorithmException 
	 * @throws GTBSSLSocketException 
	 */ 
	public GtBSSLSocketFactoryWrapper getNewSSLSFW(Context i_aCtx) throws
		UnrecoverableKeyException, KeyStoreException, 
		NoSuchAlgorithmException, GTBSSLSocketException 
	{ 
		Log.i(TAG, "Re-Establishing Connection; from scratch.");
		try { 
			m_sslSocket.close();
		} catch (IOException e) {
			Log.w(TAG, "getNewSSLSFW: Error while closing connection");
		} 
		return new GtBSSLSocketFactoryWrapper(i_aCtx);
	} 
	 
	/** 
	 * Establish another connection with server and handshake. 
	 * If this is called, call forceReHandshake afterwards. 
	 * @param i_aCtx 
	 * @return 
	 * @throws UnrecoverableKeyException 
	 * @throws KeyStoreException 
	 * @throws NoSuchAlgorithmException 
	 * @throws GTBSSLSocketException 
	 */ 
	public SSLSocket createSSLSocket (Context i_aCtx) throws
			UnrecoverableKeyException, KeyStoreException, 
			NoSuchAlgorithmException, GTBSSLSocketException 
	{ 
		m_sslSocket = (SSLSocket) createSocket(null, 0, true);
		m_sslSocket.setUseClientMode(true);
		return m_sslSocket;
	} 
	 
	/** 
	 * Create a new connection to the specified host. 
Stop searching for code, let great code find you!  Add Codota to your java IDE