ignore signature files that cannot be downloaded because of failed encoding

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@6103 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 16 years ago
parent 041d9c253e
commit 2f84736120

@ -278,19 +278,18 @@ public final class yacyRelease extends yacyVersion {
httpResponse res = null;
final String name = this.getUrl().getFileName();
byte[] signatureBytes = null;
// download signature first, if public key is available
if(this.publicKey != null) {
if (this.publicKey != null) {
final byte[] signatureData = httpClient.wget(this.getUrl().toString() + ".sig", reqHeader, 6000);
if(signatureData == null) {
Log.logSevere("yacyVersion", "download of signature " + this.getUrl().toString() + " failed");
return null;
}
try {
if (signatureData == null) {
Log.logWarning("yacyVersion", "download of signature " + this.getUrl().toString() + " failed. ignoring signature file.");
} else try {
signatureBytes = Base64Order.standardCoder.decode(new String(signatureData, "UTF8").trim(), "decode signature");
} catch (UnsupportedEncodingException e) {
Log.logSevere("yacyVersion", "download of signature " + this.getUrl().toString() + " failed: unsupported encoding");
return null;
Log.logWarning("yacyVersion", "download of signature " + this.getUrl().toString() + " failed: unsupported encoding");
}
// in case that the download of a signature file failed (can be caused by bad working http servers), then it is assumed that no signature exists
}
try {
final httpClient client = new httpClient(120000, reqHeader);
@ -302,22 +301,20 @@ public final class yacyRelease extends yacyVersion {
} else {
download = new File(storagePath, name);
}
if(this.publicKey != null) {
if (this.publicKey != null && signatureBytes != null) {
// copy to file and check signature
SignatureOutputStream verifyOutput = null;
try {
verifyOutput = new SignatureOutputStream(new FileOutputStream(download), CryptoLib.signAlgorithm, publicKey);
FileUtils.copyToStream(new BufferedInputStream(res.getDataAsStream()), new BufferedOutputStream(verifyOutput));
if(!verifyOutput.verify(signatureBytes)) {
throw new IOException("Bad Signature!");
}
if (!verifyOutput.verify(signatureBytes)) throw new IOException("Bad Signature!");
} catch (NoSuchAlgorithmException e) {
throw new IOException("No such algorithm");
} catch (SignatureException e) {
throw new IOException("Signature exception");
} finally {
if(verifyOutput != null)
if (verifyOutput != null)
verifyOutput.close();
}
// Save signature
@ -335,8 +332,7 @@ public final class yacyRelease extends yacyVersion {
Log.logSevere("yacyVersion", "download of " + this.getName() + " failed: " + e.getMessage());
if (download != null && download.exists()) {
FileUtils.deletedelete(download);
if (download.exists())
Log.logWarning("yacyVersion", "could not delete file "+ download);
if (download.exists()) Log.logWarning("yacyVersion", "could not delete file "+ download);
}
download = null;
} finally {
@ -469,7 +465,7 @@ public final class yacyRelease extends yacyVersion {
}
String script = null;
String scriptFileName = null;
if(serverSystem.isWindows){
if (serverSystem.isWindows) {
final File startType = new File(sb.getRootPath(), "DATA/yacy.noconsole".replace("/", File.separator));
String starterFile = "startYACY_debug.bat";
if (startType.exists()) starterFile = "startYACY.bat"; // startType noconsole

Loading…
Cancel
Save