Skip to content

Commit

Permalink
Resolve line ending canonicalization issue on Windows (#84)
Browse files Browse the repository at this point in the history
  • Loading branch information
mehle committed Apr 9, 2024
1 parent 38ce1a4 commit 769ba20
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions duo-client/src/main/java/com/duosecurity/client/Http.java
Original file line number Diff line number Diff line change
Expand Up @@ -314,30 +314,30 @@ protected String canonRequest(String date, int sigVersion)
String canonParam;
String canonBody;
if (sigVersion == 1) {
canon += method.toUpperCase() + System.lineSeparator();
canon += host.toLowerCase() + System.lineSeparator();
canon += uri + System.lineSeparator();
canon += method.toUpperCase() + "\n";
canon += host.toLowerCase() + "\n";
canon += uri + "\n";
canon += canonQueryString();
} else if (sigVersion == 2) {
canon += date + System.lineSeparator();
canon += method.toUpperCase() + System.lineSeparator();
canon += host.toLowerCase() + System.lineSeparator();
canon += uri + System.lineSeparator();
canon += date + "\n";
canon += method.toUpperCase() + "\n";
canon += host.toLowerCase() + "\n";
canon += uri + "\n";
canon += canonQueryString();
} else if (sigVersion == 5) {
canon += date + System.lineSeparator();
canon += method.toUpperCase() + System.lineSeparator();
canon += host.toLowerCase() + System.lineSeparator();
canon += uri + System.lineSeparator();
canon += date + "\n";
canon += method.toUpperCase() + "\n";
canon += host.toLowerCase() + "\n";
canon += uri + "\n";
if ("POST".equals(method) || "PUT".equals(method)) {
canonParam = System.lineSeparator();
canonParam = "\n";
canonBody = Util.bytes_to_hex(Util.hash(hashingAlgorithm, canonJSONBody()));
} else {
canonParam = canonQueryString() + System.lineSeparator();
canonParam = canonQueryString() + "\n";
canonBody = Util.bytes_to_hex(Util.hash(hashingAlgorithm, ""));
}
canon += canonParam;
canon += canonBody + System.lineSeparator();
canon += canonBody + "\n";
canon += Util.bytes_to_hex(Util.hash(hashingAlgorithm, canonXDuoHeaders()));
}

Expand Down

0 comments on commit 769ba20

Please sign in to comment.