|  | @@ -403,10 +403,34 @@ bool CurlFtp::setFtpIPAndPort(const std::string& IP, const int port)
 | 
	
		
			
				|  |  |      m_port = port;
 | 
	
		
			
				|  |  |      m_ftpUrl = "ftp://" + m_IP + ":" + std::to_string(m_port);
 | 
	
		
			
				|  |  |      FMTLOG_INFO("Set ftpUrl = {}", m_ftpUrl);
 | 
	
		
			
				|  |  | +    m_isSftp = false;
 | 
	
		
			
				|  |  | +    return true;
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +/* 设置SFTP的IP和端口 */
 | 
	
		
			
				|  |  | +bool CurlFtp::setSftpIPAndPort(const std::string& IP, const int port)
 | 
	
		
			
				|  |  | +{
 | 
	
		
			
				|  |  | +    m_IP = IP;
 | 
	
		
			
				|  |  | +    m_port = port;
 | 
	
		
			
				|  |  | +    m_ftpUrl = "sftp://" + m_IP + ":" + std::to_string(m_port);
 | 
	
		
			
				|  |  | +    FMTLOG_INFO("Set sftpUrl = {}", m_ftpUrl);
 | 
	
		
			
				|  |  | +    m_isSftp = true;
 | 
	
		
			
				|  |  |      return true;
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +/* 设置是否忽略SSL证书,使用SFTP不建议忽略 */
 | 
	
		
			
				|  |  | +void CurlFtp::setIgnoreSSLCert(bool isIgnore)
 | 
	
		
			
				|  |  | +{
 | 
	
		
			
				|  |  | +    m_isIgnoreSSLCert = isIgnore;
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +/* 设置CA证书文件 */
 | 
	
		
			
				|  |  | +void CurlFtp::setCaCertFile(const std::string& caCertFile)
 | 
	
		
			
				|  |  | +{
 | 
	
		
			
				|  |  | +    m_caCertFile = caCertFile;
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  /* 设置用户名和密码 */
 | 
	
		
			
				|  |  |  bool CurlFtp::setFtpUsernameAndPassword(const std::string& username, const std::string& password)
 | 
	
	
		
			
				|  | @@ -685,6 +709,22 @@ bool CurlFtp::downloadFile(const std::string& remoteFile, const std::string& loc
 | 
	
		
			
				|  |  |      curl_easy_setopt(curl, CURLOPT_XFERINFODATA, nullptr);
 | 
	
		
			
				|  |  |      /* 启用下载进度回调函数 */
 | 
	
		
			
				|  |  |      curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0L);
 | 
	
		
			
				|  |  | +    /* 判断是否是SFTP */
 | 
	
		
			
				|  |  | +    if(m_isSftp)
 | 
	
		
			
				|  |  | +    {
 | 
	
		
			
				|  |  | +        /* 判断是否需要设置CA证书 */
 | 
	
		
			
				|  |  | +        if(m_isIgnoreSSLCert)
 | 
	
		
			
				|  |  | +        {
 | 
	
		
			
				|  |  | +            /* 忽略证书验证 */
 | 
	
		
			
				|  |  | +            curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
 | 
	
		
			
				|  |  | +            /* 忽略主机名验证 */
 | 
	
		
			
				|  |  | +            curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
 | 
	
		
			
				|  |  | +        } else
 | 
	
		
			
				|  |  | +        {
 | 
	
		
			
				|  |  | +            /* 设置CA证书 */
 | 
	
		
			
				|  |  | +            curl_easy_setopt(curl, CURLOPT_CAINFO, m_caCertFile.c_str());
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      /* 发送请求 */
 | 
	
		
			
				|  |  |      CURLcode res = curl_easy_perform(curl);
 |