Subject: FTPS with certificate not working
Date: 2021-11-22 03:15:54
From: Melody
Source: ftps-certificate-not-working
----------------------------------------------------------------------

Following will be my code for connecting to FTPS, there is no password on p12 certificate. 

    client.SecureDataTransfers = True
    AddHandler client.CertificateRequired, AddressOf client_File_CertificateRequired
    client.Connect(FtpObject.HostName, Integer.Parse(FtpObject.PortNumber), SslSecurityMode.Explicit)
    client.Authenticate(FtpObject.UserName, FtpObject.Password)
    
    Private Sub client_File_CertificateRequired(ByVal sender As Object, ByVal e As ComponentPro.Security.CertificateRequiredEventArgs)
            e.Certificates = New X509Certificate2Collection(New X509Certificate2(FtpObject.SshPrivateKeyPath, ""))
    End Sub

**Certificate Information**
Encryption algorithm = TLSv1.2: AES256-SHA256, 2048 bit RSA, AES256-SHA256 TLSv1.2 Kx=RSA Au=RSA Enc=AES(256) Mac=SHA256 Cryptographic protocol = TLS/SSL Explicit encryption, TLSv1.2 **Following is the error received:**
ComponentPro.Net.TlsException: Certificate does not have a private key. ---> ComponentPro.Net.TlsException: Certificate does not have a private key. ---> System.Security.Cryptography.CryptographicException: Certificate does not have a private key. at c_ls.c_726be0b4(c_wz , Boolean , Boolean ) at c_fd.c_7007f8d7(c_wz , Boolean , Boolean ) at c_fd.c_3bd7b77c(c_wz , Boolean , Boolean ) at c_wz.c_58d2c182(Boolean ) at c_wz.c_6449b9db(Byte[] , SignatureHashAlgorithm , Boolean ) at c_ua.c_2bc3047b(Byte[] , Int32 , Int32 , c_ss ) at c_ua.c_8d3f7a18(Byte[] , Int32 , Int32 ) at c_jt.c_1042b92c(Byte[] , Int32 , Int32 ) at c_jt.c_2fb37a89() --- End of inner exception stack trace --- at c_jt.c_2fb37a89() at c_jt.c_d7acd670() at c_yq.c_d7acd670() at c_d.c_7f3b5988(SslConfigBase ) at ComponentPro.Net.Ftp.c_b06d9818(SslConfigBase , FtpSslExplicitAuthType , AsyncOperation ) at ComponentPro.Net.Ftp.c_d8db87dc(String , Int32 , SslConfigBase , SslSecurityMode , FtpSslExplicitAuthType , AsyncOperation ) --- End of inner exception stack trace --- at ComponentPro.Net.Ftp.c_d8db87dc(String , Int32 , SslConfigBase , SslSecurityMode , FtpSslExplicitAuthType , AsyncOperation ) at ComponentPro.Net.Ftp.Connect(String serverName, Int32 serverPort, SslSecurityMode security) ---------------------------------------------------------------------- Note: This question has been asked on the Q&A forum of Thang Dang's fraudulent ComponentPro brand If you purchased anything from ComponentPro, you have been scammed. Contact the payment processor who sold you the license and ask for your money back. Back to ComponentPro Q&A Forum Index