]> git.proxmox.com Git - qemu-server.git/commitdiff
spice: read cert subject name directly using Net::SSLeay
authorDietmar Maurer <dietmar@proxmox.com>
Thu, 18 Jul 2013 05:28:35 +0000 (07:28 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Thu, 18 Jul 2013 05:28:35 +0000 (07:28 +0200)
We now depend on libnet-ssleay-perl

PVE/API2/Qemu.pm
control.in

index dede2e4ad279058e6380b721c7dea660c8fb0988..5cda6baacb3a1d87632258804273d6fd2b5c6d7b 100644 (file)
@@ -3,6 +3,7 @@ package PVE::API2::Qemu;
 use strict;
 use warnings;
 use Cwd 'abs_path';
+use Net::SSLeay;
 
 use PVE::Cluster qw (cfs_read_file cfs_write_file);;
 use PVE::SafeSyslog;
@@ -1379,7 +1380,18 @@ __PACKAGE__->register_method({
        my $host = `hostname -f` || PVE::INotify::nodename();
        chomp $host;
 
-       my $subject = "OU=PVE Cluster Node, O=Proxmox Virtual Environment, CN=$host";
+       # read x509 subject
+       my $filename = "/etc/pve/local/pve-ssl.pem";
+       my $bio = Net::SSLeay::BIO_new_file($filename, 'r');
+       my $x509 = Net::SSLeay::PEM_read_bio_X509($bio);
+       Net::SSLeay::BIO_free($bio);
+       my $nameobj =  Net::SSLeay::X509_get_subject_name($x509);
+       my $subject = Net::SSLeay::X509_NAME_oneline($nameobj);
+       Net::SSLeay::X509_free($x509);
+
+       # remote-viewer wants comma as seperator (not '/')
+       $subject =~ s!^/!!;
+       $subject =~ s!/(\w+=)!,$1!g;
 
        my $cacert = PVE::Tools::file_get_contents("/etc/pve/pve-root-ca.pem", 8192);
        $cacert =~ s/\n/\\n/g;
index 0397c6c9d60413c851a368841e27066ac0c4e297..ea9da460f3df4205cd6b68cc6b871410484a00a7 100644 (file)
@@ -3,7 +3,7 @@ Version: @@VERSION@@-@@PKGRELEASE@@
 Section: admin
 Priority: optional
 Architecture: @@ARCH@@
-Depends: libc6 (>= 2.7-18), perl (>= 5.10.0-19), libterm-readline-gnu-perl, pve-qemu-kvm (>= 1.4-4) | pve-qemu-kvm-2.6.18, netcat-traditional, libpve-storage-perl, pve-cluster, redhat-cluster-pve, libjson-perl, libjson-xs-perl, libio-multiplex-perl
+Depends: libc6 (>= 2.7-18), perl (>= 5.10.0-19), libterm-readline-gnu-perl, pve-qemu-kvm (>= 1.4-4) | pve-qemu-kvm-2.6.18, netcat-traditional, libpve-storage-perl, pve-cluster, redhat-cluster-pve, libjson-perl, libjson-xs-perl, libio-multiplex-perl, libnet-ssleay-perl
 Conflicts: netcat-openbsd
 Maintainer: Proxmox Support Team <support@proxmox.com>
 Description: Qemu Server Tools