Skip to content

Commit 7b0dc82

Browse files
author
wlanboy
committed
hasSpiffeIdentitym und OtherName formatHex
1 parent bc67b90 commit 7b0dc82

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

src/main/java/com/wlanboy/javahttpclient/client/TlsInspectorService.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public Map<String, Object> inspect(String url) {
6969
X509Certificate[] chain = chainRef.get();
7070
if (chain != null && chain.length > 0) {
7171
String spiffe = extractSpiffe(chain[0]);
72-
result.put("isMtls", spiffe != null);
72+
result.put("hasSpiffeIdentity", spiffe != null);
7373
if (spiffe != null) result.put("spiffeId", spiffe);
7474
result.put("chain", serializeChain(chain));
7575
}
@@ -123,7 +123,6 @@ private List<String> extractSans(X509Certificate cert) {
123123
if (sans == null) return result;
124124
for (List<?> san : sans) {
125125
int type = (Integer) san.get(0);
126-
String value = san.get(1).toString();
127126
String prefix = switch (type) {
128127
case 0 -> "OtherName";
129128
case 1 -> "Email";
@@ -133,6 +132,10 @@ private List<String> extractSans(X509Certificate cert) {
133132
case 7 -> "IP";
134133
default -> "Type" + type;
135134
};
135+
Object raw = san.get(1);
136+
String value = (raw instanceof byte[] bytes)
137+
? HexFormat.of().formatHex(bytes)
138+
: raw.toString();
136139
result.add(prefix + ":" + value);
137140
}
138141
} catch (CertificateParsingException ignored) {}

0 commit comments

Comments
 (0)