NTP-33102: SSL Handshake 525 Attribution correction (#14733)

This commit is contained in:
Raaj Gopal
2025-01-30 12:50:11 +05:30
committed by GitHub
parent 415f2e83e0
commit a5a76cda8c
9 changed files with 86 additions and 8 deletions

View File

@@ -218,6 +218,15 @@ abstract class ApResponseCallback {
description = getString(R.string.technical_issue)
}
}
ApiConstants.API_SECURED_CONNECTION_EXCEPTION -> {
fetchNewKeyFromFirebaseAndRestart()
statusCode = ApiConstants.API_SECURED_CONNECTION_EXCEPTION
methodName = NetworkErrorType.SECURED_CONNECTION_EXCEPTION.name
AppServiceManager.application.apply {
title = getString(R.string.secure_connection_issue)
description = getString(R.string.secure_connection_issue_description)
}
}
ApiConstants.API_CODE_SSL_HANDSHAKE_EXCEPTION,
ApiConstants.API_ERROR_PEER_UNVERIFIED -> {
fetchNewKeyFromFirebaseAndRestart()

View File

@@ -50,6 +50,7 @@ enum class NetworkErrorType {
UNKNOWN_HOST,
JSON_PARSE,
CONNECT_ERROR,
SECURED_CONNECTION_EXCEPTION,
}
fun handleGlobalErrorEvent(

View File

@@ -23,6 +23,7 @@ import com.navi.common.network.ApiConstants.API_CODE_UNKNOWN_HOST
import com.navi.common.network.ApiConstants.API_ERROR_PEER_UNVERIFIED
import com.navi.common.network.ApiConstants.API_INTERNAL_SERVER_ERROR
import com.navi.common.network.ApiConstants.API_NOT_FOUND
import com.navi.common.network.ApiConstants.API_SECURED_CONNECTION_EXCEPTION
import com.navi.common.network.ApiConstants.API_WRONG_ERROR_RESPONSE
import com.navi.common.network.ApiConstants.IO_EXCEPTION_ERROR
import com.navi.common.network.ApiConstants.NO_INTERNET
@@ -285,6 +286,8 @@ fun getErrorTitle(title: String, isNae: Boolean, statusCode: Int): String {
AppServiceManager.application.getString(R.string.no_internet_connection)
statusCode == API_CODE_SLOW_NETWORK ->
AppServiceManager.application.getString(R.string.internet_too_slow)
statusCode == API_SECURED_CONNECTION_EXCEPTION ->
AppServiceManager.application.getString(R.string.secure_connection_issue)
statusCode == API_CODE_ERROR ||
statusCode == API_CODE_SOCKET_TIMEOUT ||
statusCode == API_WRONG_ERROR_RESPONSE ||
@@ -308,6 +311,8 @@ fun getErrorDescription(description: String, isNae: Boolean, statusCode: Int): S
)
statusCode == API_CODE_SLOW_NETWORK ->
AppServiceManager.application.getString(R.string.check_internet_connectivity)
statusCode == API_SECURED_CONNECTION_EXCEPTION ->
AppServiceManager.application.getString(R.string.secure_connection_issue_description)
statusCode == API_CODE_ERROR ||
statusCode == API_CODE_SOCKET_TIMEOUT ||
statusCode == API_WRONG_ERROR_RESPONSE ||

View File

@@ -26,6 +26,7 @@ object ApiConstants {
const val API_ERROR_PEER_UNVERIFIED = 26
const val IO_EXCEPTION_ERROR = 27
const val API_CODE_SLOW_NETWORK = 28
const val API_SECURED_CONNECTION_EXCEPTION = 29
// Server error
const val API_SUCCESS_CODE = 200
@@ -38,5 +39,13 @@ object ApiConstants {
const val API_NOT_FOUND = 404
const val API_INTERNAL_SERVER_ERROR = 500
const val API_BAD_GATEWAY = 502
/**
* Status code 525 denotes SSL handshake issue between Cloudfare / Gateway and the origin
* Server. We shouldn't be appending this from client side based on SSLHandShake or
* UnVerifiedPeerExceptions received from okhttp java IO exception since these would be for
* client side. The gateway itself will send 525 which is the BE API Code error, hence added new
* status code for this case and corrected the error message shown to the customer.
*/
const val API_CODE_SSL_HANDSHAKE_EXCEPTION = 525
}

View File

@@ -62,7 +62,7 @@ fun handleException(e: Throwable, tag: String? = null): ErrorMessage {
if (isNetworkPoor(maxBandwidth, networkSpeed, signalLevel, signalType)) {
errorMessage.statusCode = ApiConstants.API_CODE_SLOW_NETWORK
} else {
errorMessage.statusCode = ApiConstants.API_CODE_SSL_HANDSHAKE_EXCEPTION
errorMessage.statusCode = ApiConstants.API_SECURED_CONNECTION_EXCEPTION
}
} else {
errorMessage.statusCode = ApiConstants.API_CODE_ERROR

View File

@@ -54,6 +54,7 @@ import com.navi.common.network.ApiConstants.API_CODE_SLOW_NETWORK
import com.navi.common.network.ApiConstants.API_CODE_SOCKET_TIMEOUT
import com.navi.common.network.ApiConstants.API_CODE_SSL_HANDSHAKE_EXCEPTION
import com.navi.common.network.ApiConstants.API_CODE_UNKNOWN_HOST
import com.navi.common.network.ApiConstants.API_SECURED_CONNECTION_EXCEPTION
import com.navi.common.network.ApiConstants.API_WRONG_ERROR_RESPONSE
import com.navi.common.network.ApiConstants.NO_INTERNET
import com.navi.common.network.fetchNewKeyFromFirebaseAndRestart
@@ -345,10 +346,12 @@ object CommonUtils {
errorMessage.statusCode = API_CODE_SLOW_NETWORK
} else {
errorMessage.message =
AppServiceManager.application.getString(R.string.something_went_wrong)
AppServiceManager.application.getString(R.string.secure_connection_issue)
errorMessage.description =
AppServiceManager.application.getString(R.string.technical_issue)
errorMessage.statusCode = API_CODE_SSL_HANDSHAKE_EXCEPTION
AppServiceManager.application.getString(
R.string.secure_connection_issue_description
)
errorMessage.statusCode = API_SECURED_CONNECTION_EXCEPTION
}
}
} else {
@@ -400,6 +403,18 @@ object CommonUtils {
AppServiceManager.application.getString(R.string.internet_too_slow) +
"_"
}
API_SECURED_CONNECTION_EXCEPTION -> {
errorMessage.message =
AppServiceManager.application.getString(R.string.secure_connection_issue)
errorMessage.description =
AppServiceManager.application.getString(
R.string.secure_connection_issue_description
)
errorMessage.trace =
(errorMessage.trace ?: "") +
AppServiceManager.application.getString(R.string.secure_connection_issue) +
"_"
}
API_CODE_ERROR,
API_CODE_SOCKET_TIMEOUT,
API_WRONG_ERROR_RESPONSE,

View File

@@ -90,6 +90,29 @@ fun getNoInternetData(
)
}
fun getSecureConnectionErrorData(
context: Context,
statusCode: Int? = null,
apiUrl: String? = null,
logMessage: String? = null,
errorMetaData: ErrorMetaData? = null,
showFullScreenError: Boolean = false,
): GenericErrorResponse {
return GenericErrorResponse(
actions = listOf(Action(context.getString(R.string.retry))),
assetDetails = AssetDetails(WIFI_ERROR_ICON),
message = context.getString(R.string.secure_connection_issue_description),
title = context.getString(R.string.secure_connection_issue),
optionalNote = null,
code = SECURE_CONNECTION,
statusCode = statusCode,
apiUrl = apiUrl,
logMessage = logMessage,
errorMetaData = errorMetaData,
showFullScreenError = showFullScreenError,
)
}
fun getSlowInternetData(
context: Context,
statusCode: Int? = null,
@@ -213,6 +236,7 @@ fun getEditAccountData(context: Context): GenericWarningResponse {
const val GENERAL_ERROR = "generic_error_screen"
const val NO_INTERNET = "internet_connectivity_error_screen"
const val SLOW_INTERNET = "slow_internet_error_screen"
const val SECURE_CONNECTION = "secure_connection_error_screen"
const val SOCKET_TIMEOUT = "socket_timeout"
const val HL_NO_BANK_DISCOVERED = "hl_no_bank_discovered"
const val AADHAR_VERIFICATION_CANCELED = "AADHAR_VERIFICATION_CANCELED"

View File

@@ -26,6 +26,7 @@ import com.navi.common.network.ApiConstants.API_ERROR_NO_USER_FOUND
import com.navi.common.network.ApiConstants.API_FORBIDDEN
import com.navi.common.network.ApiConstants.API_INTERNAL_SERVER_ERROR
import com.navi.common.network.ApiConstants.API_NOT_FOUND
import com.navi.common.network.ApiConstants.API_SECURED_CONNECTION_EXCEPTION
import com.navi.common.network.ApiConstants.API_WRONG_ERROR_RESPONSE
import com.navi.common.network.ApiConstants.NO_INTERNET
import com.navi.common.network.handleException
@@ -38,6 +39,7 @@ import com.navi.common.utils.CommonNaviAnalytics
import com.navi.common.utils.getApiFailedData
import com.navi.common.utils.getErrorData
import com.navi.common.utils.getNoInternetData
import com.navi.common.utils.getSecureConnectionErrorData
import com.navi.common.utils.getSlowInternetData
import com.navi.common.utils.getSocketTimeOutData
import com.navi.common.utils.isNetworkAvailable
@@ -168,6 +170,19 @@ abstract class BaseVM(
cancelable,
)
}
API_SECURED_CONNECTION_EXCEPTION -> {
Triple(
getSecureConnectionErrorData(
AppServiceManager.application,
error.statusCode,
apiUrl = error.apiUrl,
logMessage = error.message,
errorMetaData = errorMetaData,
),
errorTag,
cancelable,
)
}
API_CODE_SOCKET_TIMEOUT -> {
Triple(
getSocketTimeOutData(

View File

@@ -12,11 +12,11 @@ import com.navi.common.network.ApiConstants.API_BAD_REQUEST
import com.navi.common.network.ApiConstants.API_CODE_CONNECT_EXCEPTION
import com.navi.common.network.ApiConstants.API_CODE_ERROR
import com.navi.common.network.ApiConstants.API_CODE_SOCKET_TIMEOUT
import com.navi.common.network.ApiConstants.API_CODE_SSL_HANDSHAKE_EXCEPTION
import com.navi.common.network.ApiConstants.API_CODE_UNKNOWN_HOST
import com.navi.common.network.ApiConstants.API_ERROR_NO_USER_FOUND
import com.navi.common.network.ApiConstants.API_ERROR_PEER_UNVERIFIED
import com.navi.common.network.ApiConstants.API_INTERNAL_SERVER_ERROR
import com.navi.common.network.ApiConstants.API_SECURED_CONNECTION_EXCEPTION
import com.navi.common.network.ApiConstants.API_SUCCESS_CODE
import com.navi.common.network.ApiConstants.API_SUCCESS_CODE_204
import com.navi.common.network.ApiConstants.API_WRONG_ERROR_RESPONSE
@@ -240,7 +240,7 @@ class SuccessHandlerNetwork : NetworkResponseProcessor(API_SUCCESS_CODE) {
}
class SSLHandshakeExceptionHandlerNetwork :
NetworkResponseProcessor(API_CODE_SSL_HANDSHAKE_EXCEPTION) {
NetworkResponseProcessor(API_SECURED_CONNECTION_EXCEPTION) {
override fun <T> handleResponse(response: Response<GenericResponse<T>>): RepoResult<T> {
return RepoResult(
data = null,
@@ -248,11 +248,11 @@ class SSLHandshakeExceptionHandlerNetwork :
ErrorMessage(
message = response.message() ?: message,
description = description,
statusCode = API_CODE_SSL_HANDSHAKE_EXCEPTION,
statusCode = API_SECURED_CONNECTION_EXCEPTION,
appRequestId = getRequestIdFromResponse(response),
vertical = getVerticalFromResponse(response),
),
statusCode = API_CODE_SSL_HANDSHAKE_EXCEPTION,
statusCode = API_SECURED_CONNECTION_EXCEPTION,
warning = response.body()?.warning,
errors = response.body()?.errors,
)