fix serialization of older certificates

This commit is contained in:
Zlatin Balevsky
2019-11-06 18:09:50 +00:00
parent af99dee4a3
commit 739dbc7a24
2 changed files with 9 additions and 6 deletions

View File

@@ -115,11 +115,13 @@ class Certificate {
daos.write(infoHash.getRoot())
name.write(daos)
issuer.write(daos)
if (comment == null)
daos.write((byte) 0)
else {
daos.write((byte) 1)
comment.write(daos)
if (version == 2) {
if (comment == null)
daos.write((byte) 0)
else {
daos.write((byte) 1)
comment.write(daos)
}
}
daos.write(sig)
daos.close()
@@ -131,7 +133,7 @@ class Certificate {
@Override
public int hashCode() {
version.hashCode() ^ infoHash.hashCode() ^ timestamp.hashCode() ^ name.hashCode() ^ issuer.hashCode()
version.hashCode() ^ infoHash.hashCode() ^ timestamp.hashCode() ^ name.hashCode() ^ issuer.hashCode() ^ Objects.hashCode(comment)
}
@Override

View File

@@ -73,6 +73,7 @@ class CertificateClient {
try {
cert = new Certificate(new ByteArrayInputStream(tmp))
} catch (IOException | InvalidSignatureException ignore) {
log.log(Level.WARNING, "certificate creation failed",ignore)
continue
}
if (cert.infoHash == e.infoHash)