@@ -164,7 +164,7 @@ private void InitializeService()
164164 } ) ;
165165 application = builder . Build ( ) ;
166166 application . UseHttpsRedirection ( ) ;
167- var path = $ " { SharedData . Config . clusterFileDirectory } cache";
167+ var path = Path . Combine ( SharedData . Config . clusterFileDirectory , $ " cache") ;
168168 // application.UseStaticFiles();
169169 application . MapGet ( "/download/{hash}" , ( context ) => HttpServiceProvider . LogAndRun ( context , ( ) =>
170170 {
@@ -205,11 +205,11 @@ private void InitializeService()
205205 /// </returns>
206206 protected X509Certificate2 LoadAndConvertCert ( )
207207 {
208- X509Certificate2 cert = X509Certificate2 . CreateFromPemFile ( $ " { SharedData . Config . clusterFileDirectory } certifications/cert.pem",
209- $ " { SharedData . Config . clusterFileDirectory } certifications/key.pem") ;
208+ X509Certificate2 cert = X509Certificate2 . CreateFromPemFile ( Path . Combine ( SharedData . Config . clusterFileDirectory , $ " certifications/cert.pem") ,
209+ Path . Combine ( SharedData . Config . clusterFileDirectory , $ " certifications/key.pem") ) ;
210210 byte [ ] pfxCert = cert . Export ( X509ContentType . Pfx ) ;
211211 SharedData . Logger . LogDebug ( $ "将 PEM 格式的证书转换为 PFX 格式") ;
212- using ( var file = File . Create ( $ " { SharedData . Config . clusterFileDirectory } certifications/cert.pfx") )
212+ using ( var file = File . Create ( Path . Combine ( SharedData . Config . clusterFileDirectory , $ " certifications/cert.pfx") ) )
213213 {
214214 file . Write ( pfxCert ) ;
215215 }
@@ -257,7 +257,7 @@ await socket.EmitAsync("enable", (SocketIOResponse resp) =>
257257 host = SharedData . Config . HOST ,
258258 port = SharedData . Config . PORT ,
259259 version = SharedData . Config . clusterVersion ,
260- byoc = SharedData . Config . byoc ,
260+ byoc = SharedData . Config . bringYourOwnCertficate ,
261261 noFastEnable = SharedData . Config . noFastEnable ,
262262 flavor = new
263263 {
@@ -445,6 +445,11 @@ private async Task DownloadFile(string hash, string path, bool force = false)
445445 /// <returns></returns>
446446 public async Task RequestCertification ( )
447447 {
448+ if ( SharedData . Config . bringYourOwnCertficate )
449+ {
450+ SharedData . Logger . LogDebug ( $ "{ nameof ( SharedData . Config . bringYourOwnCertficate ) } 为 true,跳过请求证书……") ;
451+ return ;
452+ }
448453 await socket . EmitAsync ( "request-cert" , ( SocketIOResponse resp ) =>
449454 {
450455 var data = resp ;
@@ -456,10 +461,10 @@ await socket.EmitAsync("request-cert", (SocketIOResponse resp) =>
456461 string ? certString = cert . GetString ( ) ;
457462 string ? keyString = key . GetString ( ) ;
458463
459- string certPath = $ " { SharedData . Config . clusterFileDirectory } certifications/cert.pem";
460- string keyPath = $ " { SharedData . Config . clusterFileDirectory } certifications/key.pem";
464+ string certPath = Path . Combine ( SharedData . Config . clusterFileDirectory , $ " certifications/cert.pem") ;
465+ string keyPath = Path . Combine ( SharedData . Config . clusterFileDirectory , $ " certifications/key.pem") ;
461466
462- Directory . CreateDirectory ( $ " { SharedData . Config . clusterFileDirectory } certifications") ;
467+ Directory . CreateDirectory ( Path . Combine ( SharedData . Config . clusterFileDirectory , $ " certifications") ) ;
463468
464469 using ( var file = File . Create ( certPath ) )
465470 {
0 commit comments