mirror of
https://git.proxmox.com/git/qemu-server
synced 2025-05-28 12:35:09 +00:00
add read_x509_subject_spice
Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
This commit is contained in:
parent
26d63c8c69
commit
1481f3f23c
@ -1381,18 +1381,8 @@ __PACKAGE__->register_method({
|
||||
$proxy = $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 $subject = PVE::QemuServer::read_x509_subject_spice($filename);
|
||||
|
||||
my $cacert = PVE::Tools::file_get_contents("/etc/pve/pve-root-ca.pem", 8192);
|
||||
$cacert =~ s/\n/\\n/g;
|
||||
|
@ -4851,4 +4851,21 @@ sub get_current_qemu_machine {
|
||||
return $current || $default || 'pc';
|
||||
}
|
||||
|
||||
sub read_x509_subject_spice {
|
||||
my ($filename) = @_;
|
||||
|
||||
# read x509 subject
|
||||
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;
|
||||
|
||||
return $subject;
|
||||
}
|
||||
1;
|
||||
|
Loading…
Reference in New Issue
Block a user