Hi @StewartBW ,
You can use the Convert.ToBase64String
method to convert the certificate to a Base64 string.
Then format the Base64 string to adhere to the RFC 2426 specification by spliting the Base64 string into 72-character lines, prefixed by a space.
Function FormatBase64String(ByVal base64String As String) As String
Const lineLength As Integer = 72
Dim formattedString As New StringBuilder()
Dim currentIndex As Integer = 0
While currentIndex < base64String.Length
Dim length As Integer = Math.Min(lineLength, base64String.Length - currentIndex)
formattedString.Append(" ") ' Add a space at the beginning of each line
formattedString.AppendLine(base64String.Substring(currentIndex, length))
currentIndex += length
End While
Return formattedString.ToString()
End Function
Best Regards.
Jiachen Li
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment". Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.