Skip to content

Commit 9aa9b93

Browse files
committed
fix ipv6 formattig
1 parent 18a6b9e commit 9aa9b93

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

stdlib/src/ssl/cert.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,12 +164,16 @@ pub(crate) mod ssl_cert {
164164
// IPv4
165165
format!("{}.{}.{}.{}", ip[0], ip[1], ip[2], ip[3])
166166
} else if ip.len() == 16 {
167-
// IPv6 - use standard library for canonical compressed format
167+
// IPv6 - format with all zeros visible (not compressed)
168168
let ip_addr = std::net::Ipv6Addr::from([
169169
ip[0], ip[1], ip[2], ip[3], ip[4], ip[5], ip[6], ip[7], ip[8],
170170
ip[9], ip[10], ip[11], ip[12], ip[13], ip[14], ip[15],
171171
]);
172-
ip_addr.to_string()
172+
let s = ip_addr.segments();
173+
format!(
174+
"{:X}:{:X}:{:X}:{:X}:{:X}:{:X}:{:X}:{:X}",
175+
s[0], s[1], s[2], s[3], s[4], s[5], s[6], s[7]
176+
)
173177
} else {
174178
// Fallback for unexpected length
175179
String::from_utf8_lossy(ip).into_owned()

0 commit comments

Comments
 (0)