Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ FriendlyName

unsafe string Internal.Cryptography.Pal.CertificatePal.FriendlyName
getset

Implements Internal.Cryptography.ICertificatePal.

Definition at line 166 of file CertificatePal.cs.

167 {
168 get
169 {
170 int pcbData = 0;
171 if (!global::Interop.crypt32.CertGetCertificateContextPropertyString(_certContext, CertContextPropId.CERT_FRIENDLY_NAME_PROP_ID, null, ref pcbData))
172 {
173 return string.Empty;
174 }
175 int num = (pcbData + 1) / 2;
176 Span<char> span = ((num > 256) ? ((Span<char>)new char[num]) : stackalloc char[num]);
178 fixed (char* pvData = &MemoryMarshal.GetReference(span2))
179 {
180 if (!global::Interop.crypt32.CertGetCertificateContextPropertyString(_certContext, CertContextPropId.CERT_FRIENDLY_NAME_PROP_ID, (byte*)pvData, ref pcbData))
181 {
182 return string.Empty;
183 }
184 }
185 return new string(span2.Slice(0, pcbData / 2 - 1));
186 }
187 set
188 {
189 string text = ((value == null) ? string.Empty : value);
191 try
192 {
193 CRYPTOAPI_BLOB cRYPTOAPI_BLOB = new CRYPTOAPI_BLOB(checked(2 * (text.Length + 1)), (byte*)(void*)intPtr);
194 if (!global::Interop.crypt32.CertSetCertificateContextProperty(_certContext, CertContextPropId.CERT_FRIENDLY_NAME_PROP_ID, CertSetPropertyFlags.None, &cRYPTOAPI_BLOB))
195 {
196 throw Marshal.GetLastWin32Error().ToCryptographicException();
197 }
198 }
199 finally
200 {
202 }
203 }
204 }
static void FreeHGlobal(IntPtr hglobal)
Definition Marshal.cs:1680
static unsafe IntPtr StringToHGlobalUni(string? s)
Definition Marshal.cs:1310