Skip to content

Commit

Permalink
Add temp solution to get certs for pc_instance cert providers (#1833)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #1833

This is just an intermediary solution for allow us to test tls data distribution from stage service to onedocker containers. After we build data transmission from PC Service via PC Instance repo, we will replace the implementation here with actually getting the certificates from pc_instance.

Reviewed By: danbunnell

Differential Revision: D40656809

fbshipit-source-id: dfa56dfb48516b48a748d23034708e1a7ab412ae
  • Loading branch information
YigeZhu authored and facebook-github-bot committed Oct 27, 2022
1 parent 35a2529 commit f30e59f
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from typing import Optional

from fbpcs.infra.certificate.certificate_provider import CertificateProvider
from fbpcs.infra.certificate.sample_tls_certificates import SAMPLE_CA_CERTIFICATE
from fbpcs.private_computation.entity.private_computation_instance import (
PrivateComputationInstance,
)
Expand All @@ -26,4 +27,4 @@ def __init__(self, pc_instance: PrivateComputationInstance) -> None:
def get_certificate(self) -> Optional[str]:
# TODO: implement this by retrieving ca certificate
# from pc instance repo.
raise NotImplementedError
return SAMPLE_CA_CERTIFICATE
7 changes: 6 additions & 1 deletion fbpcs/infra/certificate/pc_instance_server_certificate.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from typing import Optional

from fbpcs.infra.certificate.certificate_provider import CertificateProvider
from fbpcs.infra.certificate.sample_tls_certificates import SAMPLE_SERVER_CERTIFICATE
from fbpcs.private_computation.entity.private_computation_instance import (
PrivateComputationInstance,
)
Expand All @@ -29,4 +30,8 @@ def get_certificate(self) -> Optional[str]:
"""
# TODO: implement this by retrieving server certificate
# from pc instance repo.
raise NotImplementedError

# This is a intermediate stage for us to do testing and
# there is no security risk of returning a sample
# static certificate
return SAMPLE_SERVER_CERTIFICATE
57 changes: 57 additions & 0 deletions fbpcs/infra/certificate/sample_tls_certificates.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

# pyre-strict

# This is sample certificates generated with host study123.pci.facebook.com

SAMPLE_CA_CERTIFICATE = """-----BEGIN CERTIFICATE-----
MIID4jCCAsoCCQDmSibtviQ+hzANBgkqhkiG9w0BAQsFADCBsTELMAkGA1UEBhMC
VVMxEzARBgNVBAgMCkNhbGlmb3JuaWExEzARBgNVBAcMCk1lbmxvIFBhcmsxFzAV
BgNVBAoMDk1ldGEgUGxhdGZvcm1zMRwwGgYDVQQLDBNQcml2YXRlIENvbXB1dGF0
aW9uMSIwIAYDVQQDDBlzdHVkeTEyMy5wY2kuZmFjZWJvb2suY29tMR0wGwYJKoZI
hvcNAQkBFg55aWdlemh1QGZiLmNvbTAgFw0yMjEwMDUyMTA5NTZaGA8yMDUwMDIy
MDIxMDk1NlowgbExCzAJBgNVBAYTAlVTMRMwEQYDVQQIDApDYWxpZm9ybmlhMRMw
EQYDVQQHDApNZW5sbyBQYXJrMRcwFQYDVQQKDA5NZXRhIFBsYXRmb3JtczEcMBoG
A1UECwwTUHJpdmF0ZSBDb21wdXRhdGlvbjEiMCAGA1UEAwwZc3R1ZHkxMjMucGNp
LmZhY2Vib29rLmNvbTEdMBsGCSqGSIb3DQEJARYOeWlnZXpodUBmYi5jb20wggEi
MA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDJzBRGXEaEjz4zNhbq/BLMP2BG
V/e2YwJme9UKapxuPIYR64Zau5wGfvArGU3wz6lcbtu6lNS1Sfbh1l4YFTqq8mcJ
o7luJRpY9z4GYzHoJcX43x5aWAtIqNzJprXhpvQmdadiTn2ct9FhhOdWlb5p71KF
ShoREB3dIISjhIAM73eWJjN10uswsgG6CVsAYoRoKNqewCagHWKX0OTB/eBeTeDD
w8yYc+YkHXSJFNCt9+f4w5gGvkzivTo7aph9OnG69E3nd1jGnju7mbf6YH+lj87Q
j5WXT5VcvZy7eZn0eTgxF+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