Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use OS keychain to load certificates and private keys #154

Open
danielealbano opened this issue Jul 10, 2022 · 0 comments
Open

Use OS keychain to load certificates and private keys #154

danielealbano opened this issue Jul 10, 2022 · 0 comments
Labels
enhancement New feature or request hacktoberfest hacktoberfest
Projects
Milestone

Comments

@danielealbano
Copy link
Owner

cachegrand currently loads the certificates and private keys directly from a local file but this is not a secure approach because the process can be potentially dumped and an attacker would easily have access to the private key.

In addition, the current implementation requires the server to be restarted if the certificate is rotated which is extremely destructive.

To avoid these scenario cachegrand should use the operating system keychain and rely on an external authorized process to update / rotate the certificates / private keys stored in there.

Here an example of how to populate a keychain

    key_serial_t keyring = add_key("keyring", "localhost", NULL, 0, 0);
    printf("The Keyring id is <%jx>\n", (uintmax_t)keyring);
    if (keyring == -1) {
        perror("add_key keyring");
        exit(EXIT_FAILURE);
    }

    size_t rsa_cert_len = 0, rsa_key_len = 0;
    char *rsa_cert = read_the_rsa_certificate_file(&rsa_cert_len);
    char *rsa_key = read_the_rsa_private_key_file(&rsa_key_len);

    if (add_key("tls_cert", "public-key", rsa_cert, rsa_cert_len, keyring) == -1) {
        perror("add_key tls_cert");
        return EXIT_FAILURE;
    }
    printf("Public key added to the keyring\n");

    if (add_key("tls_priv", "private-key", rsa_key, rsa_key_len, keyring) == -1) {
        perror("add_key tls_cert");
        return EXIT_FAILURE;
    }
    printf("Private key added to the keyring\n");
@danielealbano danielealbano created this issue from a note in cachegrand (Ready for Work) Jul 10, 2022
@danielealbano danielealbano added the enhancement New feature or request label Jul 10, 2022
@danielealbano danielealbano added this to the v0.5 milestone Jul 10, 2022
@danielealbano danielealbano added the hacktoberfest hacktoberfest label Sep 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request hacktoberfest hacktoberfest
Projects
cachegrand
  
Ready for Work
Development

No branches or pull requests

1 participant