Skip to content

Allow using pre-generated certificates #57

Open
@louisroyer

Description

@louisroyer

When using oauth, a new NRF certificate is generated at each restart of the NRF, and a new certificate is generated by the NRF for each NF at registration time, making hard to have different NFs on multiple machines not sharing a common filesystem.
When using a certificate from a read-only volume or from a docker secret, the NRF fails with the following:

nrf  | 2025-03-04T10:36:10.592280016Z [INFO][NRF][Init] generate new NRF cert [context.go:100][InitNrfContext()]
nrf  | 2025-03-04T10:36:10.594107273Z [ERRO][NRF][Init] NRF init: gen cert file create: open /run/secrets/openssl_nrf_sbi_pem: read-only file system [init.go:51][NewApp()]
nrf  | 2025-03-04T10:36:10.594123284Z [ERRO][NRF][Main] NRF Run Error: NRF init: gen cert file create: open /run/secrets/openssl_nrf_sbi_pem: read-only file system [main.go:37][main()]
  1. Please allow using existing certificate if the file exists.
    nrfCertPath := config.GetNrfCertPemPath()
    logger.InitLog.Infof("generate new NRF cert")
    nrfContext.NrfCert, err = oauth.GenerateCertificate(
    string(nrfContext.NrfNfProfile.NfType), nrfContext.Nrf_NfInstanceID,
    nrfCertPath, nrfContext.NrfPubKey, nrfContext.RootCert, nrfContext.RootPrivKey)
    if err != nil {
    return errors.Wrapf(err, "NRF init")
  2. Same here:
    // Re-generate new NF's Certificate to new file
    _, err = oauth.GenerateCertificate(
    nfType, nfId, newCertPath, nfPubkey, nrfContext.RootCert, nrfContext.RootPrivKey)
    if err != nil {
    return errors.Wrapf(err, "sign NF cert")
    }
    }
  3. And allow using a configurable basepath + filename for each NF certificate (specified by configuration file), or (ideally) retrieve NFs certificates directly from http at registration time.
    nfCertPath := oauth.GetNFCertPath(factory.NrfConfig.GetCertBasePath(), nfType, "")
    newCertPath := oauth.GetNFCertPath(factory.NrfConfig.GetCertBasePath(), nfType, nfId)

    https://github.com/free5gc/openapi/blob/6ef25ba56c887f5925b166dcc57cf5f10ed1e455/oauth/oauth.go#L303-L306

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions