#!/usr/bin/awk -f

BEGIN{
    start1="\"-----BEGINCERTIFICATE-----";
    start2="-----BEGINCERTIFICATE-----";
    end1="-----ENDCERTIFICATE-----";
    end2="-----ENDCERTIFICATE-----\",";
}

{
    if($0~"https_public_content") {
        printf "%s", $1;
        for(i=2;i<=NF;i++) {
            if($i==start1)
                printf "%s", "\"-----BEGIN CERTIFICATE-----\\n";
            else if($i==start2)
                printf "%s",  "-----BEGIN CERTIFICATE-----\\n";
            else if($i==end1)
                printf "%s", "-----END CERTIFICATE-----\\n";
            else if($i==end2)
                printf "%s", "-----END CERTIFICATE-----\",";
            else if($i=="")
                continue
            else
                printf "%s", $i"\\n"
        }
    }
    else print $0
}


