Skip to content

Commit 3bc579d

Browse files
authored
Update configure-ssl-certificate-in-code.md
1 parent b5952eb commit 3bc579d

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

articles/app-service/configure-ssl-certificate-in-code.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ The `WEBSITE_LOAD_CERTIFICATES` app setting makes the specified certificates acc
5252

5353
In C# code, you access the certificate by the certificate thumbprint. The following code loads a certificate with the thumbprint `E661583E8FABEF4C0BEF694CBC41C28FB81CD870`.
5454

55-
```csharp
55+
```c#
5656
using System;
5757
using System.Linq;
5858
using System.Security.Cryptography.X509Certificates;
@@ -76,6 +76,8 @@ using (X509Store certStore = new X509Store(StoreName.My, StoreLocation.CurrentUs
7676

7777
// Use certificate
7878
Console.WriteLine(cert.FriendlyName);
79+
80+
// Consider to call Dispose() on the certificate after it's being used, avaliable in .NET 4.6 and later
7981
}
8082
```
8183

@@ -109,12 +111,13 @@ The `WEBSITE_LOAD_CERTIFICATES` app settings makes the specified certificates ac
109111

110112
The certificate file names are the certificate thumbprints. The following C# code shows how to load a public certificate in a Linux app.
111113

112-
```csharp
114+
```c#
113115
using System;
116+
using System.IO;
114117
using System.Security.Cryptography.X509Certificates;
115118

116119
...
117-
var bytes = System.IO.File.ReadAllBytes("/var/ssl/certs/<thumbprint>.der");
120+
var bytes = File.ReadAllBytes("/var/ssl/certs/<thumbprint>.der");
118121
var cert = new X509Certificate2(bytes);
119122

120123
// Use the loaded certificate
@@ -137,12 +140,13 @@ If you need to load a certificate file that you upload manually, it's better to
137140
138141
The following C# example loads a public certificate from a relative path in your app:
139142
140-
```csharp
143+
```c#
141144
using System;
145+
using System.IO;
142146
using System.Security.Cryptography.X509Certificates;
143147
144148
...
145-
var bytes = System.IO.File.ReadAllBytes("~/<relative-path-to-cert-file>");
149+
var bytes = File.ReadAllBytes("~/<relative-path-to-cert-file>");
146150
var cert = new X509Certificate2(bytes);
147151
148152
// Use the loaded certificate

0 commit comments

Comments
 (0)