This is an old revision of the document!


09 - Android Security (2)

  • Description:
  • Practical part:

Lecture

Practical

Task 1 - Fetch web page through HTTP (3p)

Create an application that downloads a web page through HTTP. The activity includes a text box and a button. The user introduces an URL and clicks on the button to obtain the contents of the web page.

When the button is clicked, check network connectivity through the ConnectivityManager. Then, perform network operations in an AsyncTask. Use HttpURLConnection for performing HTTP GET requests and InputStream for receiving the reply.

Resources:

Task 2 - Fetch web page through HTTPS (1p)

Modify the previous application in order to obtain web pages through HTTPS. Use HttpsURLConnection.

Resources:

Task 3 - Display system trust store (3p)

The Android system includes a system (default) trust store, which includes a list of trusted Certificate Authorities (CAs).

Modify the previous application in order to display the system trust store using TrustManager.

Resources:

Task 4 - Use a custom trust store (3p)

The previous application will not be able to fetch web pages on a server with a certificate that is issued by an unknown CA. For example: https://certs.cac.washington.edu/CAtest/, which uses certificate issued by UW Services Certificate Authority (which is not trusted by Android by default). Extend the application in order to be able to access this URL, by loading and using a custom trust store.

Steps:

  • Save certificate from server and put it in res/raw/
  • Load trusted CAs from file
  • Create a KeyStore object and insert the trusted CAs
  • Obtain an instance of TrustManagerFactory and initialise it
  • Obtain an instance of SSLContext and initialise it
  • Create an URL object
  • Obtain an HttpsURLConnection
  • Configure the HttpsURLConnection to use the SocketFactory from the SSLContext
  • Read from an InputStream

Resources:

Task 5 (Bonus) - Use both system and custom trust stores (3p)

In the previous task, the application uses only the custom trust store and ignores the system trust store. Extend the application by allowing the usage of both custom and system trust stores.

Resources:

osp/lectures/lecture-security2.1481474749.txt.gz ยท Last modified: 2016/12/11 18:45 by laura.gheorghe
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0