|
|
@@ -797,7 +797,34 @@ int CAsyncSslSocketLayer::InitSSLConnection(bool clientMode,
|
|
|
|
|
|
//Create bios
|
|
|
m_sslbio = BIO_new(BIO_f_ssl());
|
|
|
- BIO_new_bio_pair(&m_ibio, 32768, &m_nbio, 32768);
|
|
|
+ // WORKAROUND: Upload over TLS 1.3 fails for specific sizes in relation to OpenSSL buffer size.
|
|
|
+ // For 32768 buffer, the sizes are 32725-32746, 65471-65492, 98217-98238 (tested up to 1048576)
|
|
|
+ // Do not know how to fix that, so as a workaround, using buffer size that does not result in the problem.
|
|
|
+ unsigned long TransferSize = 0;
|
|
|
+ if (main != NULL)
|
|
|
+ {
|
|
|
+ TransferSize = static_cast<unsigned long>(GetSocketOptionVal(OPTION_MPEXT_TRANSFER_SIZE));
|
|
|
+ }
|
|
|
+ unsigned BufferKBs = 32;
|
|
|
+ unsigned long BufferSize;
|
|
|
+ do
|
|
|
+ {
|
|
|
+ BufferSize = BufferKBs * 1024;
|
|
|
+ int Remainder = TransferSize % BufferSize;
|
|
|
+ int BufferCount = (TransferSize / BufferSize) + (Remainder > 0 ? 1 : 0);
|
|
|
+ int ProblemHigh = BufferSize - (BufferCount * 22);
|
|
|
+ int ProblemLow = ProblemHigh - 21;
|
|
|
+ if ((ProblemLow <= Remainder) && (Remainder <= ProblemHigh))
|
|
|
+ {
|
|
|
+ BufferKBs++;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ while (true);
|
|
|
+ BIO_new_bio_pair(&m_ibio, BufferSize, &m_nbio, BufferSize);
|
|
|
|
|
|
if (!m_sslbio || !m_nbio || !m_ibio)
|
|
|
{
|