Product SiteDocumentation Site

3.4.9. isSecure

The isSecure method can be used to find out if a given connection is secure. A connection will be classified secure if it is either encrypted or it is running on a channel which is not vulnerable to eavesdropping (like a UNIX domain socket). If successful it returns 1 for a secure connection and 0 for an insecure connection. If an error occurred, -1 will be returned. The following code demonstrates the use of isSecure:

Example 3.20. Using virConnectIsSecure

# Example-19.py
#!/usr/bin/env python3
import sys
import libvirt

conn = None
try:
    conn = libvirt.open("qemu:///system")
except libvirt.libvirtError as e:
    print(repr(e), file=sys.stderr)
    exit(1)

print('Connection is secure: '+str(conn.isSecure()))

conn.close()
exit(0)