From: Dietmar Maurer Date: Thu, 18 Jul 2013 05:28:35 +0000 (+0200) Subject: spice: read cert subject name directly using Net::SSLeay X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=451b2b815e4407c9ebe160606f422f6114382bb3;hp=943340a62874641f450a9a610db6ab164019e199;p=qemu-server.git spice: read cert subject name directly using Net::SSLeay We now depend on libnet-ssleay-perl --- diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm index dede2e4a..5cda6baa 100644 --- a/PVE/API2/Qemu.pm +++ b/PVE/API2/Qemu.pm @@ -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; diff --git a/control.in b/control.in index 0397c6c9..ea9da460 100644 --- a/control.in +++ b/control.in @@ -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 Description: Qemu Server Tools