SU3File: Also look in config dir for signer certificate

This commit is contained in:
zzz
2016-07-18 14:39:35 +00:00
parent 37ebf04bb5
commit 767476ea51
3 changed files with 23 additions and 3 deletions

View File

@ -314,6 +314,7 @@ public class SU3File {
if (_certFile != null) {
_signerPubkey = loadKey(_certFile);
} else {
// look in both install dir and config dir for the signer cert
KeyRing ring = new DirKeyRing(new File(_context.getBaseDir(), "certificates"));
try {
_signerPubkey = ring.getKey(_signer, _contentType.getName(), _sigType);
@ -322,8 +323,24 @@ public class SU3File {
ioe.initCause(gse);
throw ioe;
}
if (_signerPubkey == null)
throw new IOException("unknown signer: " + _signer + " for content type: " + _contentType.getName());
if (_signerPubkey == null) {
boolean diff = true;
try {
diff = !_context.getBaseDir().getCanonicalPath().equals(_context.getConfigDir().getCanonicalPath());
} catch (IOException ioe) {}
if (diff) {
ring = new DirKeyRing(new File(_context.getConfigDir(), "certificates"));
try {
_signerPubkey = ring.getKey(_signer, _contentType.getName(), _sigType);
} catch (GeneralSecurityException gse) {
IOException ioe = new IOException("keystore error");
ioe.initCause(gse);
throw ioe;
}
}
if (_signerPubkey == null)
throw new IOException("unknown signer: " + _signer + " for content type: " + _contentType.getName());
}
}
}
_headerVerified = true;