Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nullpointer on every message #13

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 7 additions & 12 deletions src/io/calidog/certstream/CertStreamCertificate.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@
public class CertStreamCertificate extends X509Certificate {
private HashMap<String, String> subject;
private HashMap<String, String[]> extensions;
private HashMap<String, String> issuer;

private double notBefore;
private double notAfter;

private String asDer;
String sigAlg;

String serialNumber;

Expand All @@ -31,12 +32,9 @@ private CertStreamCertificate() {}
public static CertStreamCertificate fromPOJO(CertStreamCertificatePOJO pojo) throws CertificateException {
CertStreamCertificate fullCertificate = new CertStreamCertificate();

if (pojo.asDer.isEmpty())
{
return null;
}
fullCertificate.issuer = pojo.issuer;

fullCertificate.asDer = pojo.asDer;
fullCertificate.sigAlg = pojo.sigAlg;

fullCertificate.extensions = pojo.extensions;

Expand Down Expand Up @@ -191,13 +189,10 @@ public void verify(PublicKey publicKey, Provider provider) throws CertificateExc
super.verify(publicKey, provider);
}

private byte[] memoizedEncodedCert = null;
@Override
public byte[] getEncoded() throws CertificateEncodingException {
if (memoizedEncodedCert == null) {
memoizedEncodedCert = Base64.getDecoder().decode(asDer);
}
return Arrays.copyOf(memoizedEncodedCert, memoizedEncodedCert.length);
public byte[] getEncoded() {

return new byte[1];
}

/**Not implemented*/
Expand Down
6 changes: 4 additions & 2 deletions src/io/calidog/certstream/CertStreamCertificatePOJO.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ public class CertStreamCertificatePOJO {

HashMap<String, String> subject;

HashMap<String,String> issuer;

// values can be either strings or lists of strings, so we use a a custom deserializer
// that converts strings into singleton arrays
HashMap<String, String[]> extensions;
Expand All @@ -22,8 +24,8 @@ public class CertStreamCertificatePOJO {
@SerializedName("not_after")
double notAfter;

@SerializedName("as_der")
String asDer;
@SerializedName("signature_algorithm")
String sigAlg;

@SerializedName("serial_number")
String serialNumber;
Expand Down
11 changes: 3 additions & 8 deletions src/io/calidog/certstream/CertStreamMessageData.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ public class CertStreamMessageData {

String updateType;

CertStreamCertificate leafCert;
String certLink;

CertStreamCertificate[] chain;
CertStreamCertificate leafCert;

long certIndex;

Expand All @@ -36,12 +36,7 @@ public static CertStreamMessageData fromPOJO(CertStreamMessageDataPOJO pojo) thr

fullData.leafCert = CertStreamCertificate.fromPOJO(pojo.leafCert);

fullData.chain = new CertStreamCertificate[pojo.chain.length];

for (int i = 0; i < fullData.chain.length; i++)
{
fullData.chain[i] = CertStreamCertificate.fromPOJO(pojo.chain[i]);
}
fullData.certLink = pojo.certLink;

fullData.source = pojo.source;

Expand Down
5 changes: 3 additions & 2 deletions src/io/calidog/certstream/CertStreamMessageDataPOJO.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ public class CertStreamMessageDataPOJO {
@SerializedName("update_type")
String updateType;

@SerializedName("cert_link")
String certLink;

@SerializedName("leaf_cert")
CertStreamCertificatePOJO leafCert;

CertStreamCertificatePOJO[] chain;

@SerializedName("cert_index")
long certIndex;

Expand Down