Hi Matthias,<div>Thanks for your excellent explanation. It works now with the hellolibvirt example. I still have a problem. It don't want to be forced to enter a password. So I tried to set the URI to esx://user:pass@ESX_host/?no_verify=1. But that does not work. It anyway asks for password. Providing the user in the URI works, but not the password. I know that this is not secure at all passing the password in the URI, but the script has to be able to run automatically. Is there another way to provide username and password, for example by using virConnectOpenAuth() not with the virConnectAuthPtrDefault but with an array containing the username and password already?</div>
<div>Remember, I can not exchange public key or something, since I use ESXi 4.0.</div><div><br></div><div>Thank you so much for your help.</div><div>Adrian</div><div><br><div class="gmail_quote">2010/7/3 Matthias Bolte <span dir="ltr"><<a href="mailto:matthias.bolte@googlemail.com">matthias.bolte@googlemail.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">2010/7/3 adrian wyssen <<a href="mailto:wyssenadrian@gmail.com">wyssenadrian@gmail.com</a>>:<br>
<div><div></div><div class="h5">> Hello everyone<br>
> I am really new to libvirt and I have to use it with ESXi. I was writing<br>
> code for listing the virtual machines in a ESXi server. If I connect me with<br>
> the virsh to the ESXi server, it works. But since I can not create any<br>
> certificates on the server (ESXi does not have any console...) I have to use<br>
> the no_verify option (esx://host/?no_verify=1)<br>
> I want to do the same with the API, but when I use this string in the uri<br>
> parameter of the following code<br>
> conn = virConnectOpenAuth(uri, virConnectAuthPtrDefault, 0);<br>
> the system returns "libvir: Remote error : Cannot access CA certificate<br>
> '/etc/pki/CA/cacert.pem': No such file or directory<br>
> No connection to hypervisor"<br>
> What method can I use to be able to connect to the server by ignoring the<br>
> missing certificate? Another question is: Are there any example codes for<br>
> using ESX(i), because as I said I am really new with libvirt and I did not<br>
> find any examples.<br>
> Thanks a lot for your help.<br>
> Adrian<br>
<br>
</div></div>The certificates libvirt is complaining about have nothing to do with<br>
the certificates for ESX(i).<br>
<br>
By default libvirt uses a TLS connection to a remote libvirtd (a<br>
daemon). This daemon is used to allow remote management of hypervisors<br>
that don't have remote capabilities on their own, like QEMU. For<br>
ESX(i) this daemon is not necessary, because libvirt directly uses the<br>
remote SOAP API provided by the ESX(i) server.<br>
<br>
By default libvirt uses a HTTPS connection to the ESX(i) server.<br>
Proper HTTPS requires correctly configured SSL certificates, this<br>
certificates are different from the certificates for libvirt's TLS<br>
connection to libvirtd. In case of a default ESX(i) installation the<br>
ESX(i) server has auto-generated self-signed certificates. And in<br>
general those cannot be verified by your client because your client<br>
doesn't have the cacert.pem that corresponds to the private key that<br>
the ESX(i) server used to sign the auto-generated self-signed<br>
certificates.<br>
<br>
That's the reason why libvirt allows you to disable those certificate<br>
check by appending ?no_verify=1 to the URI.<br>
<br>
libvirt complains here about the for the TLS connection to a remote<br>
libvirtd. This is a bit cryptic error that appears because libvirt<br>
don't know what to do with the URI you gave to it and as last option<br>
it tries to connect to a libvirtd on the remote server hoping that the<br>
libvirtd there knows what to do with the URI.<br>
<br>
The typical reason why this happens is that your libvirt is build<br>
without ESX support. But you said 'virsh -c esx://host/?no_verify=1'.<br>
Therefore, I assume that's not the case here.<br>
<br>
Could it be that you have multiple version of libvirt installed? One<br>
that has ESX support enabled and is used by virsh and one that has ESX<br>
support disabled and that your program links against?<br>
<br>
Regarding example code: There is no special ESX libvirt example code,<br>
because libvirt is designed to provide hypervisor independent API.<br>
<br>
You can take a look at the examples directory. For example the<br>
hellolibvirt example:<br>
<br>
   ./examples/hellolibvirt/hellolibvirt esx://host/?no_verify=1<br>
<br>
If that still gives you that certificate error, try:<br>
<br>
   LIBVIRT_DEBUG=1 LIBVIRT_LOG_OUTPUTS=1:stderr<br>
./examples/hellolibvirt/hellolibvirt esx://host/?no_verify=1<br>
<br>
It should list lines like<br>
<br>
13:13:23.189: debug : virRegisterDriver:927 : registering ESX as driver 5<br>
...<br>
13:13:23.189: debug : do_open:1242 : trying driver 5 (ESX) ...<br>
<br>
If there is no virRegisterDriver or do_open line regarding ESX then<br>
your libvirt is build without ESX support. But i wonder why virsh<br>
works then.<br>
<br>
Recent (unreleased) libvirt has better error reporting for this<br>
situation and tells you when you try to use an URI scheme that was<br>
disabled, instead of reporting unexpected certificate errors.<br>
<font color="#888888"><br>
Matthias<br>
</font></blockquote></div><br></div>