Skip to main content
Version: V1.3.0

Primary and standby network security and authentication

Primary and standby seekdb instances synchronize and call services over RPC. By default, connections are not authenticated and traffic is plaintext: any process on the network could impersonate a node or eavesdrop. If you need stronger security, enable TLS. Both sides must present certificates signed by the same CA, which gives you:

  • Mutual authentication: The server checks the client certificate and the client checks the server certificate, which mitigates man-in-the-middle attacks and unauthorized nodes.
  • Encryption: All RPC traffic is encrypted. After the TLS handshake, peers derive a symmetric key and all gRPC messages use it; nothing sensitive is sent in plaintext.

Architecture​

Primary node                     Standby node
┌─────────────────┐ ┌─────────────────┐
│ ObGrpcServer │ │ ObGrpcClient │
│ (SslServer │◄────mTLS────►│ (SslCredentials│
│ Credentials) │ │ ) │
│ wallet/ │ │ wallet/ │
│ ├─ ca.pem │ │ ├─ ca.pem │ ← same CA
│ ├─ cert.pem │ │ ├─ cert.pem │
│ └─ key.pem │ │ └─ key.pem │
└─────────────────┘ └─────────────────┘

Each node keeps three files under the wallet/ directory in the process working directory:

FileContents
wallet/ca.pemCA root certificate (public key) used to verify the peer
wallet/cert.pemNode certificate (public key), with SAN for this host's IP
wallet/key.pemNode private key

Deployment​

Prerequisites​

  • Certificate files are prepared.

  • TLS must be enabled on both primary and standby. It is controlled by enable_rpc_tls.

    ParameterTypeDefaultHow it appliesDescription
    enable_rpc_tlsBOOLFalseRestartWhether TLS is enabled

Procedure​

The following uses primary IP 10.0.0.1 and standby IP 10.0.0.2. Run all commands on any machine with openssl, then distribute the files.

  1. Generate the CA

    # CA private key (4096-bit)
    openssl genrsa -out ca.key 4096

    # Self-signed CA certificate, 365 days
    openssl req -x509 -new -nodes \
    -key ca.key \
    -sha256 -days 365 \
    -subj "/O=OceanBase/CN=OceanBase-CA" \
    -out ca.pem

    Store ca.key securely; it is used to sign node certificates.

  2. Generate the primary certificate (IP: 10.0.0.1)

    PRIMARY_IP="10.0.0.1"

    # Node private key
    openssl genrsa -out primary_key.pem 2048

    # CSR
    openssl req -new \
    -key primary_key.pem \
    -subj "/O=OceanBase/CN=${PRIMARY_IP}" \
    -out primary.csr

    # Sign certificate; SAN includes primary IP and loopback
    echo "subjectAltName=IP:${PRIMARY_IP}" > primary_san.ext
    openssl x509 -req \
    -in primary.csr \
    -CA ca.pem -CAkey ca.key \
    -CAcreateserial \
    -extfile primary_san.ext \
    -days 365 -sha256 \
    -out primary_cert.pem

    # Verify SAN
    openssl x509 -in primary_cert.pem -noout -ext subjectAltName
    # Expected: IP Address:10.0.0.1, IP Address:127.0.0.1

    Keep cert.key secure for signing later node certificates.

  3. Generate the standby certificate (IP: 10.0.0.2)

    STANDBY_IP="10.0.0.2"

    openssl genrsa -out standby_key.pem 2048

    openssl req -new \
    -key standby_key.pem \
    -subj "/O=OceanBase/CN=${STANDBY_IP}" \
    -out standby.csr

    echo "subjectAltName=IP:${STANDBY_IP}" > standby_san.ext
    openssl x509 -req \
    -in standby.csr \
    -CA ca.pem -CAkey ca.key \
    -CAcreateserial \
    -extfile standby_san.ext \
    -days 365 -sha256 \
    -out standby_cert.pem

    openssl x509 -in standby_cert.pem -noout -ext subjectAltName
    # Expected: IP Address:10.0.0.2, IP Address:127.0.0.1
  4. Copy files to each node

    • Primary ($PRIMARY/wallet/)

      mkdir -p $PRIMARY/wallet
      cp ca.pem $PRIMARY/wallet/ca.pem
      cp primary_cert.pem $PRIMARY/wallet/cert.pem
      cp primary_key.pem $PRIMARY/wallet/key.pem
      chmod 600 $PRIMARY/wallet/key.pem
      chmod 644 $PRIMARY/wallet/ca.pem
      chmod 644 $PRIMARY/wallet/cert.pem
    • Standby ($STANDBY/wallet/)

      mkdir -p $STANDBY/wallet
      cp ca.pem $STANDBY/wallet/ca.pem
      cp standby_cert.pem $STANDBY/wallet/cert.pem
      cp standby_key.pem $STANDBY/wallet/key.pem
      chmod 600 $STANDBY/wallet/key.pem
      chmod 644 $STANDBY/wallet/ca.pem
      chmod 644 $STANDBY/wallet/cert.pem

Verification​

  1. Confirm TLS is active

    On primary and standby, query the virtual table:

    SELECT svr_ip, svr_port, rpc_tls_enabled, rpc_cert_expire_time FROM __all_virtual_server_stat;

    Fields:

    rpc_tls_enabled: Whether TLS is on. 1 means the server runs in TLS mode; 0 means off or plaintext.

    rpc_cert_expire_time: Expiry of wallet/cert.pem as a microsecond Unix timestamp; 0 means TLS is off.

  2. Test the handshake with openssl s_client

    # Whether the server requires a client cert (mTLS)
    # Without a client cert, handshake should fail
    openssl s_client -connect <ip>:<rpc_port> \
    -CAfile wallet/ca.pem \
    -tls1_3 2>&1 | tail -5
    # Under TLS 1.3, server rejection often shows: unexpected eof while reading

    # With client cert, handshake should succeed
    openssl s_client -connect <ip>:<rpc_port> \
    -CAfile wallet/ca.pem \
    -cert wallet/cert.pem \
    -key wallet/key.pem \
    -tls1_3 2>&1 | grep "Verify return code"
    # Expected: Verify return code: 0 (ok)

Certificate rotation​

Prefer long-lived certificates (for example 10+ years) to reduce the risk of expiry causing inconsistency between primary and standby.

When a certificate expires, rotate by replacing cert.pem and key.pem in each node's wallet/ directory. If the CA is unchanged, ca.pem does not need to change.

New connections load the updated files from wallet/; existing connections end naturally as requests complete.