+ // Try to populate the SSL certificate information.
+ try {
+ // Get the applied cipher suite string.
+ val appliedCipherString = (httpUrlConnection as HttpsURLConnection).cipherSuite
+
+ // Populate the applied cipher builder, returned separately.
+ appliedCipherBuilder.append(appliedCipherString)
+
+ // Append the applied cipher suite to the SSL information builder.
+ sslInformationBuilder.append(application.getString(R.string.applied_cipher), StyleSpan(Typeface.BOLD), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
+ sslInformationBuilder.append(colonString)
+ sslInformationBuilder.append(appliedCipherString)
+ sslInformationBuilder.append(newLineString)
+
+ // Append the peer principal to the SSL information builder.
+ sslInformationBuilder.append(application.getString(R.string.peer_principal), StyleSpan(Typeface.BOLD), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
+ sslInformationBuilder.append(colonString)
+ sslInformationBuilder.append(httpUrlConnection.peerPrincipal.toString())
+ sslInformationBuilder.append(newLineString)
+
+ // Get the server certificate.
+ val serverCertificate = httpUrlConnection.serverCertificates[0]
+
+ // Append the certificate type to the SSL information builder.
+ sslInformationBuilder.append(application.getString(R.string.certificate_type), StyleSpan(Typeface.BOLD), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
+ sslInformationBuilder.append(colonString)
+ sslInformationBuilder.append(serverCertificate.type)
+ sslInformationBuilder.append(newLineString)
+
+ // Append the certificate hash code to the SSL information builder.
+ sslInformationBuilder.append(application.getString(R.string.certificate_hash_code), StyleSpan(Typeface.BOLD), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
+ sslInformationBuilder.append(colonString)
+ sslInformationBuilder.append(serverCertificate.hashCode().toString())
+
+ // Get the available cipher suites string array.
+ val availableCipherSuitesStringArray = httpUrlConnection.sslSocketFactory.defaultCipherSuites
+
+ // Get the available cipher suites string array size.
+ val availableCipherSuitesStringArraySize = availableCipherSuitesStringArray.size
+
+ // Populate the available cipher suites, returned separately.
+ for (i in 0 until availableCipherSuitesStringArraySize) {
+ // Append a new line if a cipher is already populated.
+ if (i > 0)
+ availableCiphersBuilder.append(newLineString)
+
+ // Get the current cipher suite.
+ val currentCipherSuite = availableCipherSuitesStringArray[i]
+
+ // Append the current cipher to the list.
+ availableCiphersBuilder.append(currentCipherSuite)
+ }
+
+ // Populate the SSL certificate, returned separately.
+ sslCertificateBuilder.append(serverCertificate.toString())
+ } catch (exception: Exception) {
+ // Do nothing.
+ }
+