How to create a new iis ssl certificate request using code

Eng Ahmed 1 Reputation point
2021-08-24T03:51:42.857+00:00

How to create a new iis ssl certificate request using vb.net code and geting string result

125864-1111.png

Developer technologies | ASP.NET | Other
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Yijing Sun-MSFT 7,096 Reputation points
    2021-08-24T08:22:00.413+00:00

    Hi @Eng Ahmed ,
    You could try this to general the CSR.

    Private Sub SurroundingSub()  
        Dim rsa As Chilkat.Rsa = New Chilkat.Rsa()  
        Dim success As Boolean = rsa.GenerateKey(2048)  
      
        If success <> True Then  
            Console.WriteLine(rsa.LastErrorText)  
            Return  
        End If  
      
        Dim privKey As Chilkat.PrivateKey = rsa.ExportPrivateKeyObj()  
        Dim csr As Chilkat.Csr = New Chilkat.Csr()  
        csr.CommonName = "mysubdomain.mydomain.com"  
        csr.Country = "GB"  
        csr.State = "Yorks"  
        csr.Locality = "York"  
        csr.Company = "Internet Widgits Pty Ltd"  
        csr.CompanyDivision = "IT"  
        csr.EmailAddress = "******@mydomain.com"  
        Dim pemStr As String = csr.GenCsrPem(privKey)  
      
        If csr.LastMethodSuccess <> True Then  
            Console.WriteLine(csr.LastErrorText)  
            Return  
        End If  
      
        privKey.SavePkcs8EncryptedPemFile("password", "qa_output/privKey1.pem")  
        Dim fac As Chilkat.FileAccess = New Chilkat.FileAccess()  
        fac.WriteEntireTextFile("qa_output/csr1.pem", pemStr, "utf-8", False)  
        Console.WriteLine(pemStr)  
    End Sub  
    

    Best regards,
    Yijing Sun


    If the answer is helpful, please click "Accept Answer" and upvote it.

    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.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.