Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions scripts/install-private-ca-on-kernel/on-kernel-start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/bash

set -eux

cat > ~/.download_ca_certs.py <<EOL
#!/opt/conda/bin/python3

import sys
import json
import boto3
import botocore
import os

# must be in same region as SM Studio
CA_CERT_BUCKET = '[s3_bucket_name]'

s3 = boto3.client('s3')
objects = s3.list_objects(Bucket=CA_CERT_BUCKET)

conda_cert_file = open('/opt/conda/ssl/cacert.pem', 'a+')

# Download all cert files from bucket and append to conda ca cert file
for object in objects['Contents']:
if '/' not in object['Key']:
s3.download_file(CA_CERT_BUCKET, object['Key'], object['Key'])
current_file = open(object['Key'], 'r')
contents = current_file.read()
if "BEGIN CERTIFICATE" in contents and "END CERTIFICATE" in contents:
conda_cert_file.write(contents + "\n")
current_file.close()
os.remove(object['Key'])

conda_cert_file.close()

EOL

chmod +x ~/.download_ca_certs.py
~/.download_ca_certs.py