Changeset 104745 in vbox for trunk/src/VBox/Main
- Timestamp:
- May 21, 2024 12:52:09 PM (6 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-server/VRDEServerImpl.cpp
r104618 r104745 241 241 int VRDEServer::i_generateServerCertificate() 242 242 { 243 Utf8Str strServerCertificate = "server_cert.pem"; 244 Utf8Str strServerPrivateKey = "server_key_private.pem"; 245 mParent->i_calculateFullPath(strServerCertificate, strServerCertificate); 246 mParent->i_calculateFullPath(strServerPrivateKey, strServerPrivateKey); 247 const char *pszServerCertificate = strServerCertificate.c_str(); 248 const char *pszServerPrivateKey = strServerPrivateKey.c_str(); 249 250 int vrc = RTCrX509Certificate_Generate(pszServerCertificate, pszServerPrivateKey); 251 243 Utf8Str strServerCertificate("server_cert.pem"); 244 int vrc = mParent->i_calculateFullPath(strServerCertificate, strServerCertificate); 245 AssertRCReturn(vrc, vrc); 246 247 Utf8Str strServerPrivateKey("server_key_private.pem"); 248 vrc = mParent->i_calculateFullPath(strServerPrivateKey, strServerPrivateKey); 249 AssertRCReturn(vrc, vrc); 250 251 vrc = RTCrX509Certificate_GenerateSelfSignedRsa(RTDIGESTTYPE_SHA1, 2048 /*cBits*/, 10 * 365 * RT_SEC_1DAY, 252 0 /*fKeyUsage*/, 0 /*fExtKeyUsage*/, NULL /*pvSubjectTodo*/, 253 strServerCertificate.c_str(), strServerPrivateKey.c_str(), NULL /*pErrInfo*/); 252 254 if (RT_SUCCESS(vrc)) 253 255 { … … 255 257 mData.backup(); 256 258 259 /** @todo r=bird: These statements may trigger exceptions and leave 260 * dangling server_cert.pem & server_key_private.pem files around. 261 * Since we're not doing an active settings save here (problematic IIRC) there 262 * are probably hundreds more likely ways this could go belly up and leave those 263 * files behind. 264 * 265 * The problem is that the code relies on the _settings_ to decide whether they 266 * are there or not, and if no it creates them. If anything goes wrong before 267 * we can save settings, this function will fail to retify the situation because 268 * the file already exist and RTCrX509Certificate_GenerateSelfSignedRsa won't 269 * overwrite existing files. 270 * 271 * Klaus, some settings saving input required here! 272 */ 257 273 mData->mapProperties["Security/Method"] = Utf8Str("TLS"); 258 274 mData->mapProperties["Security/ServerCertificate"] = strServerCertificate; … … 306 322 int vrc = i_generateServerCertificate(); 307 323 if (RT_FAILURE(vrc)) 308 {309 324 LogRel(("Failed to auto generate server key and certificate: (%Rrc)\n", vrc)); 310 }311 325 } 312 326 }
Note:
See TracChangeset
for help on using the changeset viewer.