Skip to content

Conversation

rossigee
Copy link

Add proper TLS handshake verification for libvirt connections over TLS.

When connecting to libvirt over TLS, the server writes a verification byte after the TLS handshake to indicate whether the client certificate and/or IP address verification succeeded. This was not being handled, which could lead to connection issues in some environments.

This change:

  • Reads the server verification byte after TLS connection
  • Properly handles verification failures with clear error messages
  • Improves robustness of TLS connections to libvirt
  • Follows the libvirt TLS protocol as documented in go-libvirt issues

Also improves user detection fallback when /etc/passwd lookup fails by using os.Getuid() directly for container environments.

References: digitalocean/go-libvirt#89 (comment)

rossigee added 2 commits July 11, 2025 08:36
Add proper TLS handshake verification for libvirt connections over TLS.

When connecting to libvirt over TLS, the server writes a verification byte
after the TLS handshake to indicate whether the client certificate and/or
IP address verification succeeded. This was not being handled, which could
lead to connection issues in some environments.

This change:
- Reads the server verification byte after TLS connection
- Properly handles verification failures with clear error messages
- Improves robustness of TLS connections to libvirt
- Follows the libvirt TLS protocol as documented in go-libvirt issues

Also improves user detection fallback when /etc/passwd lookup fails
by using os.Getuid() directly for container environments.

References:
- digitalocean/go-libvirt#89 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant