Improved PEM/DER selection

pull/214/head
M66B 9 months ago
parent bdb7ca1ba0
commit 651802150d

@ -554,18 +554,18 @@ public class ActivitySetup extends ActivityBase implements FragmentManager.OnBac
boolean der = false; boolean der = false;
String extension = Helper.getExtension(uri.getLastPathSegment()); String extension = Helper.getExtension(uri.getLastPathSegment());
Log.i("Extension=" + extension); DocumentFile dfile = DocumentFile.fromSingleUri(context, uri);
if (!"pem".equalsIgnoreCase(extension)) String type = (dfile == null ? null : dfile.getType());
// https://pki-tutorial.readthedocs.io/en/latest/mime.html
if (!"pem".equalsIgnoreCase(extension) &&
!"application/x-pem-file".equals(type))
try { try {
DocumentFile dfile = DocumentFile.fromSingleUri(context, uri); if (type != null && type.startsWith("application/"))
String type = dfile.getType();
Log.i("Type=" + type);
if ("application/octet-stream".equals(type))
der = true; der = true;
} catch (Throwable ex) { } catch (Throwable ex) {
Log.w(ex); Log.w(ex);
} }
Log.i("DER=" + der); Log.i("Extension=" + extension + "type=" + type + " DER=" + der);
X509Certificate cert; X509Certificate cert;
CertificateFactory fact = CertificateFactory.getInstance("X.509"); CertificateFactory fact = CertificateFactory.getInstance("X.509");
@ -603,6 +603,11 @@ public class ActivitySetup extends ActivityBase implements FragmentManager.OnBac
return null; return null;
} }
@Override
protected void onExecuted(Bundle args, Void data) {
ToastEx.makeText(ActivitySetup.this, R.string.title_completed, Toast.LENGTH_LONG).show();
}
@Override @Override
protected void onException(Bundle args, Throwable ex) { protected void onException(Bundle args, Throwable ex) {
// DecoderException: unable to decode base64 string: invalid characters encountered in base64 data // DecoderException: unable to decode base64 string: invalid characters encountered in base64 data

Loading…
Cancel
Save