Skip to content

Commit

Permalink
add fingerprints from env variable
Browse files Browse the repository at this point in the history
  • Loading branch information
javaes committed Jan 19, 2017
1 parent 120baff commit 3b62430
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ session.setProxy(proxy);
// now do your API calls
```

You can add valid SSL fingerprints by adding them to the `FIGO_API_FINGERPRINTS` environment variable. Fingerprints
need to be added in HEX format without column delimiters. A column delimiter is used to indicate the next element in
the list of fingerprints.


To disable the SSL certificate pinning (not recommended) do the following:
```java
// first create the FigoSession object
Expand Down
8 changes: 7 additions & 1 deletion src/main/java/me/figo/internal/FigoTrustManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,9 @@ public void checkServerTrusted(X509Certificate[] certs, String authType) throws
throw new CertificateException("No certificate found");
} else {
String thumbprint = getThumbPrint(certs[0]);
if (!VALID_FINGERPRINTS.contains(thumbprint))
if (!VALID_FINGERPRINTS.contains(thumbprint) && !this.getFingerprintsFromEnv().contains(thumbprint)){
throw new CertificateException();
}
}
}

Expand All @@ -89,4 +90,9 @@ private static String getThumbPrint(X509Certificate cert) {
return "";
}
}

private static List<String> getFingerprintsFromEnv() {
String fingerprintList = System.getenv("FIGO_API_FINGERPRINTS");
return Arrays.asList(fingerprintList.split(":"));
}
}

0 comments on commit 3b62430

Please sign in to comment.