Skip to content

platform/tls_quictls: add support for in-memory PEM certificate (QUIC_CERTIFICATE_PEM)#5766

Open
unstabler wants to merge 7 commits intomicrosoft:mainfrom
team-unstablers:tuexport/inmemory-pem
Open

platform/tls_quictls: add support for in-memory PEM certificate (QUIC_CERTIFICATE_PEM)#5766
unstabler wants to merge 7 commits intomicrosoft:mainfrom
team-unstablers:tuexport/inmemory-pem

Conversation

@unstabler
Copy link

Description

Note
Please bear with me as I am relying on machine translation because I am not proficient in English.

Motivation

I am developing server software for macOS based on MsQuic. Since MsQuic does not currently support using SecIdentity from the macOS Security.framework (Keychain) directly, I wanted to avoid the workaround of writing PEM files to a temporary directory just to load them.

Although there is existing support for loading PKCS12 from memory, MsQuic failed to read the PKCS12 blob exported via Security.framework. According to an analysis by an LLM, this issue seems to be caused by the macOS export using legacy encryption algorithms or password enforcement that are not compatible with the current MsQuic/OpenSSL configuration.

Changes

  • Added QUIC_CERTIFICATE_PEM struct

    • This allows loading PEM certificates directly from memory.
    • Added support for certificate chains within this struct.
    • Added support for password-protected private keys within this struct.
  • Added Unit Tests

    • Added tests for the new in-memory PEM loading functionality.
    • Added tests for loading certificate chains.

Notes

  • The unit tests included in this PR were generated with the assistance of an LLM.
original text

NOTE: machine-translated
정말 웃기게도, 전 영어 문장을 쓰지 못하기 때문에 기계 번역기에 의존하고 있습니다. 양해 바랍니다.

왜 필요한가

  • MsQuic 기반으로 macOS용 서버 소프트웨어를 만들고 있습니다. macOS Keychain에 저장된 서버용 인증서(SecIdentity from Security.framework)를 MsQuic에서 다이렉트로 사용하지 못하더라도, 적어도 PEM 파일을 임시 디렉토리에 저장하는 짓 만큼은 하고 싶지 않았습니다.

  • PKCS12는 in-memory 로부터 로드하는 기능이 있긴 하지만, Security.framework를 통해 export한 인증서는 어째서인지 읽어들이지 못했습니다. LLM 모델에 따르면, Security.framework에서 export하는 PKCS12 인증서는 password-enforced 되어 있는 것도 있지만, 암호화 알고리즘이 너무 낡아서 그렇다고 하는 것 같습니다.

CHANGES

  1. In-memory로부터 인증서를 로드할 수 있도록, QUIC_CERTIFICATE_PEM struct를 추가합니다.
  • 동 struct에 대해, 인증서 체인 지원을 추가합니다.
  • 동 struct에 대해, password-protected private key 지원을 추가합니다.
  1. 1번 작업에 대한 유닛 테스트를 추가합니다.
  2. 인증서 체인 로드에 대한 유닛 테스트를 추가합니다.

NOTE

  • 유닛 테스트는 LLM이 작성하였습니다.

Testing

Do any existing tests cover this change? Are new tests needed?

Documentation

Is there any documentation impact for this change?

@unstabler unstabler requested a review from a team as a code owner February 3, 2026 23:26
@unstabler
Copy link
Author

@microsoft-github-policy-service agree company="team unstablers Inc."

@ProjectsByJackHe
Copy link
Contributor

Hey thanks for this PR. @anrossi should have the most context on TLS.

I also see usage of #ifndef _WIN32 for gating this feature. Let's be careful that this is actually the correct macro given the vast number of platforms MsQuic supports.

Properly handle `SSL_CTX_add_extra_chain_cert` failures and distinguish EOF from parse error during PEM chain processing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants