Lambda Function > S3 Upload: SSL validation failed error

0

I am working on a Lambda function that processes incoming audio files and uploads the resulting audio file to S3.

I am receiving the following error:

"errorMessage": "SSL validation failed for https://[mybucket].s3.amazonaws.com/[mypath]/[myfile].mp3 EOF occurred in violation of protocol (_ssl.c:2427)",
  "errorType": "SSLError",

I have tried uploading both a file from memory and uploading a file from a path in /tmp storage.

Same error in both cases.

I have granted the Lambda function S3 access The Lambda function and S3 bucket are in the same account and region I have used the same Execution Role with another Lambda function to write to this S3 bucket before without error

Here is my code:

import json
import boto3
from pydub import AudioSegment
from io import BytesIO
import datetime

s3_client = boto3.client('s3')

def load_audio_from_s3(bucket, key):
    obj = s3_client.get_object(Bucket=bucket, Key=key)
    return AudioSegment.from_file(BytesIO(obj['Body'].read()), format='mp3')

def upload_fileobj_to_s3(file_obj, bucket, object_name):
    file_obj.seek(0)  # Reset file pointer to the start
    s3_client.upload_fileobj(file_obj, bucket, object_name, ExtraArgs={'ACL': 'public-read'})

def lambda_handler(event, context):
    # Extracting information from the event object
    voice_file_keys = event['voice_file_keys']

    # .... process audio ...
    # .... process audio ...
    # .... process audio ...

    # Save the final product to an in-memory file
    output_buffer = BytesIO()
    datetime_str = datetime.datetime.now().strftime("%Y%m%d_%H%M%S")
    output_filename = f"{datetime_str}.mp3"
    final_product.export(output_buffer, format='mp3', parameters=["-codec:a", "libmp3lame"])

    # Upload the in-memory file to S3
    s3_object_name = f"final_audio/{output_filename}"
    upload_fileobj_to_s3(output_buffer, s3_bucket_name, s3_object_name)

    return {
        'statusCode': 200,
        'body': json.dumps(Audio {output_filename} processing and upload completed successfully.')
    }

질문됨 6달 전500회 조회
1개 답변
1
수락된 답변

Looks like that it could be the same issue https://github.com/boto/boto3/issues/3359. One of the purposed solution was boto3 upgrade https://github.com/boto/boto3/issues/3359#issuecomment-1762241082

profile pictureAWS
전문가
답변함 6달 전
profile picture
전문가
검토됨 2달 전
  • This worked - thanks!

    I was previously relying on the version of boto3 that was available in the Lambda environment (which was not the latest release).

    I added the latest release of boto3 to my Lambda layer, and that solved the SLL verification issue.

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠