This project is to implement a configuration management server. RDK devices download configurations from this server during bootup or notified when updates are available.
Webconfig supports 2 types of transport between cloud and devices
- http / webpa
- mqtt
This project is written and tested with Go 1.21.
cd $HOME/go/src/github.com/rdkcentral/webconfig
makebin/webconfig-linux-amd64 will be created.
A sample configuration file can be found at config/sample_webconfig.conf
If we want to encrypt the data in db for security, we can set a security key through an environment variable. A command like this generate a random key in base64
$ head -c 32 /dev/random | base64
ABCDEF...Specify the environ variable in the config
webconfig {
security {
encryption_key_env_name = "WEBCONFIG_KEY"
}The subdocs that need encryption can be specified in the config
encrypted_subdoc_ids = [ "privatessid", "homessid", "telcovoip", "voiceservice" ]Webconfig is designed to work with an "http-collector" service. It includes full MQTT broker capabilities and a REST api interface. The endpoint needs to be properly configure in the "mqtt" section of the config
Webconfig works with rdk devices through webpa. "webpa" and "jwt" sections need to be properly configured. If this route is not used, then the jwt should be disabled.
Devices use mqtt or webpa route send message to webconfig cloud. Webconfig supports 3 types of kafka message
- webpa state
- mqtt get
- mqtt state The actual kafka topic names can be any. Below is just an example. "topics" should include all topics. "ratelimit" can be tuned to users env.
kafka {
enabled = false
brokers = "localhost:9092"
topics = "config-version-report"
use_random_consumer_group = false
consumer_group = "webconfig"
assignor = "roundrobin"
oldest = false
ratelimit {
messages_per_second = 10
}
clusters {
mesh {
enabled = false
brokers = "localhost:19092"
topics = "staging-chi-onewifi-from-device"
use_random_consumer_group = false
consumer_group = "webconfig"
assignor = "roundrobin"
oldest = false
ratelimit {
messages_per_second = 10
}
}
}Webconfig supports secure TLS/SSL connections to Kafka brokers for both consumers and producers. This is recommended for production environments to ensure data encryption in transit and proper authentication.
TLS Configuration Options:
tls_enabled- Enable/disable TLS for Kafka connections (default: false)tls_ca_file- Path to CA certificate file(s) used to verify the broker (optional; system CA pool when unset)tls_cert_file- Path to the client certificate for mutual TLS (optional). Either a combined PEM containing the certificate and private key, or the certificate alone whentls_key_fileis settls_key_file- Path to the client private key for mutual TLS (optional). Leave unset whentls_cert_fileis a combined PEMtls_insecure_skip_verify- Skip certificate verification (insecure, for testing only, default: false)tls_server_name- Optional SNI and certificate name override (default: empty)
tls_ca_cert_file is a legacy alias for tls_ca_file, kept temporarily so one ConfigMap works with binaries that predate tls_ca_file. If both are set to the same value, that value is used. If both are set to different values, startup fails with a configuration error. If only the legacy name is set, it is used and a deprecation warning is logged. Remove the legacy name once every deployed binary reads tls_ca_file.
Kafka keeps its existing tls_enabled flag for each consumer cluster and producer. Cassandra uses its existing is_ssl_enabled flag; after TLS is enabled, both integrations use the same flat tls_* fields, including identical tls_insecure_skip_verify and tls_server_name behavior.
Consumer TLS Configuration Example:
kafka {
enabled = true
brokers = "kafka-broker:9093" # Use secure port
topics = "config-version-report"
consumer_group = "webconfig"
tls_enabled = true
tls_cert_file = "/etc/webconfig/kafka/client.pem"
tls_ca_file = "/etc/webconfig/kafka/ca.crt"
tls_insecure_skip_verify = false
tls_server_name = "kafka.example.com"
# Per-cluster TLS configuration
clusters {
mesh {
enabled = true
brokers = "kafka-mesh:9093"
topics = "staging-chi-onewifi-from-device"
tls_enabled = true
tls_cert_file = "/etc/webconfig/kafka/mesh-client.crt"
tls_key_file = "/etc/webconfig/kafka/mesh-client.key"
tls_ca_file = "/etc/webconfig/kafka/mesh-ca.crt"
tls_insecure_skip_verify = false
tls_server_name = "kafka-mesh.example.com"
}
}
}Producer TLS Configuration Example:
kafka_producer {
enabled = true
// one_line consolidates consumer and producer enqueue success under logger=kafka;
// two_line also emits the consumer processing success record and uses
// logger=kafkaproducer for producer records.
logging_mode = "one_line"
brokers = "kafka-broker:9093"
topic = "webconfig_downstream"
tls_enabled = true
tls_cert_file = "/etc/webconfig/kafka/producer-client.pem"
tls_ca_file = "/etc/webconfig/kafka/ca.crt"
tls_insecure_skip_verify = false
tls_server_name = "kafka.example.com"
}Certificate Requirements:
-
Client Certificate (mutual TLS):
tls_cert_fileis optional. When it is set, the client certificate and private key are loaded withtls.LoadX509KeyPair:- Combined PEM: leave
tls_key_fileunset.tls_cert_filemust contain both the certificate and the private key. - Separate files: set
tls_key_fileto the private key.tls_cert_filecontains only the certificate. - If client credentials are configured but cannot be loaded (missing file, invalid PEM, or a key that does not match the certificate), startup fails. TLS is never silently downgraded to server-only authentication.
tls_key_filewithouttls_cert_fileis rejected.
- Combined PEM: leave
-
CA Certificate:
tls_ca_filecontains the CA certificate(s) used to verify the Kafka broker. It is always loaded and validated, including whentls_insecure_skip_verify = true. -
Certificate Validation: All certificate files are validated at startup. The application will fail to start with clear error messages if:
- Certificate files are missing or unreadable
- Certificates are in invalid format
- Certificate and key don't match
TLS Security Best Practices:
- Use TLS in Production: Always enable TLS for production Kafka connections to encrypt data in transit
- Use mutual TLS: Provide a client certificate (
tls_cert_file, plustls_key_fileif the key is in a separate file) so the broker can authenticate the client - Verify Certificates: Never use
tls_insecure_skip_verify = truein production - it disables certificate verification and is insecure - Protect Certificate Files: Set appropriate file permissions (0600) on certificate and key files
- Use Secure Ports: Configure Kafka brokers to listen on secure ports (typically 9093 for TLS)
- Certificate Rotation: Plan for certificate rotation - the service must be restarted to pick up new certificates
Troubleshooting TLS Issues:
- Check logs for TLS-related errors during startup
- Verify certificate file paths are correct and files are readable
- Ensure Kafka brokers are configured to accept TLS connections
- Test certificate validity:
openssl x509 -in client.crt -text -noout - Verify certificate and key match:
openssl x509 -noout -modulus -in client.crt | openssl md5vsopenssl rsa -noout -modulus -in client.key | openssl md5
The main database operations are defined as an interface. Any driver that implements the interface should work. We has implemented using sqlite, cassandra and yugabytedb. After the db is properly configured, the dbinit.cql can be used to create the tables for cassandra.
$ export WEBCONFIG_KEY='ABCDEF...'
$ mkdir -p /app/logs/webconfig
$ cd $HOME/go/src/github.com/rdkcentral/webconfig
$ bin/webconfig-linux-amd64 -f config/sample_webconfig.confThis display the build date and code commit info
curl http://localhost:9000/api/v1/version
{"status":200,"message":"OK","data":{"code_git_commit":"2ac7ff4","build_time":"Thu Feb 14 01:57:26 2019 UTC","binary_version":"317f2d4","binary_branch":"develop","binary_build_time":"2021-02-10_18:26:49_UTC"}}The POST API is designed to accept binary input "Content-type: application/msgpack". A "group_id" is mandatory in the query parameter to specify the subdoc the input is meant for. Most programming languages supports HTTP would accept binary data as POST body. The example uses curl and reads the binary data from a file.
curl -s -i "http://localhost:9000/api/v1/device/010203040506/document/privatessid" -H 'Content-type: application/msgpack' --data-binary @privatessid.bin -X POST
HTTP/1.1 200 OK
Content-Type: application/json
Date: Wed, 14 Oct 2020 22:58:21 GMT
Content-Length: 29
{"status":200,"message":"OK"}The GET API read binary data in the response. The "group_id" is mandatory in the query parameter. For simplicity, the binary output is saved as a file. We can compare the 2 files to verify.
curl -s -i "http://localhost:9000/api/v1/device/010203040506/document/privatessid" > result.bin
cmp privatessid.bin result.binWhen data are prepared in DB, users are expected to call this poke API. Webconfig uses the RDK webpa service to prompt the webconfig client on the devices to download the prepared configurations.
curl -s "http://localhost:9009/api/v1/device/010203040506/poke" -X POST
RDK devices use this API to fetch data. The response is in HTTP multipart. Each part maps to a subdoc, or a logical group of configurations encoded in msgpack.
curl -s "http://localhost:9000/api/v1/device/010203040506/config"
HTTP/1.1 200 OK
Content-Type: multipart/mixed; boundary=2xKIxjfJuErFW+hmNCwEoMoY8I+ECM9efrV6EI4efSSW9QjI
Etag: 2484248953
Date: Sun, 18 Oct 2020 19:19:34 GMT
Content-Length: 578
--2xKIxjfJuErFW+hmNCwEoMoY8I+ECM9efrV6EI4efSSW9QjI
Content-type: application/msgpack
Etag: 1737259797
Namespace: privatessid
��parameters���name�Device.WiFi.Private�value�^AE��private_ssid_2g��SSID�garf_private_2g�EnableøSSIDAdvertisementEnabledïprivate_ssid_5g��SSID�garf_private_5g�EnableøSSIDAdvertisementEnabledóprivate_security_2g��Passphrase�garf_pw_2g�EncryptionMethod�AES�ModeEnabled�WPA2-Personal�private_security_5g��Passphrase�garf_pw_5g�EncryptionMethod�AES�ModeEnabled�WPA2-Personal�dataType�
--2xKIxjfJuErFW+hmNCwEoMoY8I+ECM9efrV6EI4efSSW9QjI--When data are prepared in DB, users are expected to call this poke API. Webconfig uses the RDK webpa service to prompt the webconfig client on the devices to download the prepared configurations.
curl -s "http://localhost:9009/api/v1/device/010203040506/poke?route=mqtt" -X POST