|
33 | 33 | // Configure gRPC client for LeaseService with mTLS support |
34 | 34 | builder.Services.AddSingleton(sp => |
35 | 35 | { |
36 | | - var logger = sp.GetRequiredService<ILogger<Program>>(); |
37 | | - |
38 | | - GrpcChannel channel; |
39 | | - |
| 36 | + var logger = sp.GetRequiredService<ILogger<Program>>(); |
| 37 | + |
| 38 | + GrpcChannel channel; |
| 39 | + |
40 | 40 | if (mtlsConfig.Enabled) |
41 | 41 | { |
42 | 42 | logger.LogInformation("mTLS is enabled for gRPC client connections"); |
|
61 | 61 | clientCertificate = X509Certificate2.CreateFromPem(certPem, keyPem); |
62 | 62 | logger.LogInformation("Loaded client certificate from {CertPath}", mtlsConfig.ClientCertificatePath); |
63 | 63 | } |
| 64 | + catch (FileNotFoundException fnfEx) |
| 65 | + { |
| 66 | + throw new InvalidOperationException($"Client certificate file not found: {mtlsConfig.ClientCertificatePath}", fnfEx); |
| 67 | + } |
| 68 | + catch (UnauthorizedAccessException uaEx) |
| 69 | + { |
| 70 | + throw new InvalidOperationException($"Access denied reading client certificate: {mtlsConfig.ClientCertificatePath}", uaEx); |
| 71 | + } |
| 72 | + catch (System.Security.Cryptography.CryptographicException cryptoEx) |
| 73 | + { |
| 74 | + throw new InvalidOperationException($"Invalid certificate format in {mtlsConfig.ClientCertificatePath}", cryptoEx); |
| 75 | + } |
64 | 76 | catch (Exception ex) |
65 | 77 | { |
66 | 78 | throw new InvalidOperationException($"Failed to load client certificate from {mtlsConfig.ClientCertificatePath}", ex); |
|
76 | 88 | serverCaCertificate = X509Certificate2.CreateFromPem(caPem); |
77 | 89 | logger.LogInformation("Loaded server CA certificate from {CertPath}", mtlsConfig.ServerCaCertificatePath); |
78 | 90 | } |
| 91 | + catch (FileNotFoundException fnfEx) |
| 92 | + { |
| 93 | + throw new InvalidOperationException($"Server CA certificate file not found: {mtlsConfig.ServerCaCertificatePath}", fnfEx); |
| 94 | + } |
| 95 | + catch (UnauthorizedAccessException uaEx) |
| 96 | + { |
| 97 | + throw new InvalidOperationException($"Access denied reading server CA certificate: {mtlsConfig.ServerCaCertificatePath}", uaEx); |
| 98 | + } |
| 99 | + catch (System.Security.Cryptography.CryptographicException cryptoEx) |
| 100 | + { |
| 101 | + throw new InvalidOperationException($"Invalid CA certificate format in {mtlsConfig.ServerCaCertificatePath}", cryptoEx); |
| 102 | + } |
79 | 103 | catch (Exception ex) |
80 | 104 | { |
81 | 105 | throw new InvalidOperationException($"Failed to load server CA certificate from {mtlsConfig.ServerCaCertificatePath}", ex); |
|
285 | 309 | { |
286 | 310 | var metricsService = host.Services.GetRequiredService<INodeMetricsService>(); |
287 | 311 |
|
288 | | - Node.Runtime.Observability.TelemetryConfig.ActiveLeasesGauge = |
| 312 | + Node.Runtime.Observability.TelemetryConfig.ActiveLeasesGauge = |
289 | 313 | Node.Runtime.Observability.TelemetryConfig.Meter.CreateObservableGauge( |
290 | 314 | "active_leases", |
291 | 315 | () => metricsService.GetActiveLeases(), |
292 | 316 | description: "Current number of active leases being processed"); |
293 | 317 |
|
294 | | - Node.Runtime.Observability.TelemetryConfig.AvailableSlotsGauge = |
| 318 | + Node.Runtime.Observability.TelemetryConfig.AvailableSlotsGauge = |
295 | 319 | Node.Runtime.Observability.TelemetryConfig.Meter.CreateObservableGauge( |
296 | 320 | "available_slots", |
297 | 321 | () => metricsService.GetAvailableSlots(), |
|
0 commit comments