|
4 | 4 | import android.content.Context; |
5 | 5 | import androidx.annotation.NonNull; |
6 | 6 | import android.text.TextUtils; |
| 7 | + |
7 | 8 | import com.datatheorem.android.trustkit.utils.TrustKitLog; |
8 | 9 | import java.io.IOException; |
9 | 10 | import java.io.InputStream; |
@@ -45,6 +46,7 @@ public static TrustKitConfiguration fromXmlPolicy( |
45 | 46 | builderList.addAll(readDomainConfig(parser, null)); |
46 | 47 | } else if ("debug-overrides".equals(parser.getName())) { |
47 | 48 | // The debug-overrides option is global and not tied to a specific domain |
| 49 | + |
48 | 50 | debugOverridesTag = readDebugOverrides(context, parser); |
49 | 51 | } |
50 | 52 | } |
@@ -262,6 +264,8 @@ private static DebugOverridesTag readDebugOverrides(@NonNull Context context, |
262 | 264 | // Parse the supplied certificate file |
263 | 265 | String caPathFromUser = parser.getAttributeValue(null, "src").trim(); |
264 | 266 |
|
| 267 | + caPathFromUser = formatCertPathResourceWhenId(context, caPathFromUser); |
| 268 | + |
265 | 269 | // Parse the path to the certificate bundle for src=@raw - we ignore system or user |
266 | 270 | // as the src |
267 | 271 | if (!TextUtils.isEmpty(caPathFromUser) && !caPathFromUser.equals("user") |
@@ -293,4 +297,14 @@ private static DebugOverridesTag readDebugOverrides(@NonNull Context context, |
293 | 297 | } |
294 | 298 | return result; |
295 | 299 | } |
| 300 | + |
| 301 | + private static String formatCertPathResourceWhenId(@NonNull Context context, String caPathFromUser) { |
| 302 | + if(TextUtils.isDigitsOnly(caPathFromUser.replace("@", ""))){ |
| 303 | + caPathFromUser = "@" + context.getResources() |
| 304 | + .getResourceName(Integer.parseInt(caPathFromUser.replace("@", ""))) |
| 305 | + .replace(context.getPackageName()+":", ""); |
| 306 | + } |
| 307 | + |
| 308 | + return caPathFromUser; |
| 309 | + } |
296 | 310 | } |
0 commit comments