Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/VBox/Main/idl/VirtualBox.xidl
Original file line number Diff line number Diff line change
Expand Up @@ -24900,6 +24900,26 @@ Snapshot 1 (B.vdi) Snapshot 1 (B.vdi)
</desc>
</attribute>

<method name="getVRDECertificate">
<desc>
Returns an ICertificate structure for the VRDE Server.
<result name="VERR_FILE_NOT_FOUND">
Certificate file was not found.
</result>
<result name="VBOX_E_FILE_ERROR">
Error reading certificate file.
</result>
</desc>
<param name="getCACert" type="boolean" dir="in">
<desc>
return ICertificate structure for CA certificate
</desc>
</param>
<param name="CertificateInfo" type="ICertificate" dir="return">
<desc></desc>
</param>
</method>

<method name="setVRDEProperty">
<desc>
Sets a VRDE specific property string.
Expand Down
1 change: 1 addition & 0 deletions src/VBox/Main/include/VRDEServerImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ class ATL_NO_VTABLE VRDEServer :
HRESULT getAuthLibrary(com::Utf8Str &aAuthLibrary);
HRESULT setAuthLibrary(const com::Utf8Str &aAuthLibrary);
HRESULT getVRDEProperties(std::vector<com::Utf8Str> &aVRDEProperties);
HRESULT getVRDECertificate(BOOL getCACert, ComPtr<ICertificate> &aCertificateInfo);

// wrapped IVRDEServer methods
HRESULT setVRDEProperty(const com::Utf8Str &aKey,
Expand Down
51 changes: 51 additions & 0 deletions src/VBox/Main/src-server/VRDEServerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "VRDEServerImpl.h"
#include "MachineImpl.h"
#include "VirtualBoxImpl.h"
#include "CertificateImpl.h"
#ifdef VBOX_WITH_EXTPACK
# include "ExtPackManagerImpl.h"
#endif
Expand Down Expand Up @@ -1046,6 +1047,56 @@ HRESULT VRDEServer::getVRDEExtPack(com::Utf8Str &aExtPack)
return hrc;
}

HRESULT VRDEServer::getVRDECertificate(BOOL getCACert, ComPtr<ICertificate> &aCertificateInfo)
{

RTERRINFOSTATIC ErrInfo;
RTCRX509CERTIFICATE x509certificate;
HRESULT hrc;
ComObjPtr<Certificate> ptrCertificateInfo;
Utf8Str strServerCertificate;

if (getCACert)
{
strServerCertificate = mData->mapProperties["Security/CACertificate"];
}
else
{
strServerCertificate = mData->mapProperties["Security/ServerCertificate"];
}

int vrc = mParent->i_calculateFullPath(strServerCertificate, strServerCertificate);
AssertRCReturn(vrc, VBOX_E_IPRT_ERROR);

if (RTFileExists(strServerCertificate.c_str()))
{
vrc = RTCrX509Certificate_ReadFromFile(&x509certificate, strServerCertificate.c_str(),
RTCRX509CERT_READ_F_PEM_ONLY, &g_RTAsn1DefaultAllocator,
RTErrInfoInitStatic(&ErrInfo));
if (RT_FAILURE(vrc))
{
RTCrX509Certificate_Delete(&x509certificate);
return setError(VBOX_E_FILE_ERROR, tr("Failed to read certificate '%s': %Rrc%#RTeim\n"),
strServerCertificate.c_str(), vrc, &ErrInfo.Core);
}

ptrCertificateInfo.createObject();
hrc = ptrCertificateInfo->initCertificate(&x509certificate, false, false);
if (SUCCEEDED(hrc))
{
/* set the return value */
ptrCertificateInfo.queryInterfaceTo(aCertificateInfo.asOutParam());
}
RTCrX509Certificate_Delete(&x509certificate);
}
else
{
hrc = VERR_FILE_NOT_FOUND;
}

return hrc;
}

// public methods only for internal purposes
/////////////////////////////////////////////////////////////////////////////
HRESULT VRDEServer::setVRDEExtPack(const com::Utf8Str &aExtPack)
Expand Down