summaryrefslogtreecommitdiff
path: root/src
AgeCommit message (Collapse)AuthorFilesLines
5 daysssl_key_handler: Avoid redundant c_str() callYuvakumar Selvamani1-1/+1
std::filesystem::remove() already accepts a std::filesystem::path directly. Calling certPath.c_str() first converts the path to a const char*, which is then implicitly re-converted back into a temporary path object - an unnecessary round-trip. Pass certPath directly instead. Found during review of Ia8cfbbc8eeefa6f6cc3bd8d291d93876cc869d47c (https://gerrit.openbmc.org/c/openbmc/bmcweb/+/94314), raised as a separate change per reviewer request since that change is a pure refactor already approved. Tested: - Tested on AST2600 SoC. Triggered a real hostname-change D-Bus signal (busctl set-property .../network/config xyz.openbmc_project.Network.SystemConfiguration HostName s "<NEW_HOSTNAME>") to exercise installCertificate() end-to-end. journalctl -u bmcweb confirmed the fixed remove(certPath, ec2) call ran and logged "Replace HTTPs Certificate Success", and the temp file (/tmp/hostname_cert.tmp) was removed as expected. - Verified the new cert was actually installed and served: $ curl -sk -v https://BMC_IP/redfish/v1/ -o /dev/null 2>&1 | \ grep subject: * subject: C=US; O=OpenBMC; CN=<NEW_HOSTNAME> - Verified Redfish still healthy post-reload: $ curl -sk -u BMC_USER:BMC_PASS \ -o /dev/null -w "HTTP %{http_code}\n" \ https://BMC_IP/redfish/v1/Managers/bmc HTTP 200 - Redfish Service Validator: 5830 Pass / 353 Warn / 0 Fail. Change-Id: If60533899dbbc84bb151e282e83f22ef636eb119 Signed-off-by: Yuvakumar Selvamani <yuvakumars@ami.com>
12 daysRefactor installCertificate lambdaYuvakumar Selvamani1-23/+24
Extract the long D-Bus async_method_call callback lambda in the former installCertificate() into a named function, afterInstallCertificate(), bound via std::bind_front() and wrapped in std::function, per the <10 line lambda coding standard in docs/COMMON_ERRORS.md. installCertificate() was a static, single-caller wrapper, so its body is now inlined directly into its only caller, regenerateCertificateIfHostnameChanged(), removing the redundant indirection. Tested: - Tested on AST2600 SoC. Triggered a real hostname-change D-Bus signal (busctl set-property .../network/config xyz.openbmc_project.Network.SystemConfiguration HostName s "bmc-test") to exercise regenerateCertificateIfHostnameChanged() end-to-end. journalctl -u bmcweb confirmed the new afterInstallCertificate() callback ran and logged "Replace HTTPs Certificate Success" after the real Certs.Replace D-Bus call, and the temp file (/tmp/hostname_cert.tmp) was removed as expected. - Verified the new cert was actually installed and served: $ curl -sk -v https://BMC_IP/redfish/v1/ -o /dev/null 2>&1 | grep \ subject: * subject: C=US; O=OpenBMC; CN=bmc-test - Verified Redfish still healthy post-reload: $ curl -sk -u BMC_USER:BMC_PASS -o /dev/null -w "HTTP %{http_code}\n"\ https://BMC_IP/redfish/v1/Managers/bmc HTTP 200 - Redfish Service Validator: 5830 Pass / 353 Warn / 0 Fail. Change-Id: I8cfbbc8eeefa6f6cc3bd8d291d93876cc869d47c Signed-off-by: Yuvakumar Selvamani <yuvakumars@ami.com>
12 dayswebserver_cli: Refactor setLogLevel lambdaYuvakumar Selvamani1-12/+18
Extract the long D-Bus async_method_call callback lambda in setLogLevel() into a named function, afterSetLogLevel(), bound via std::bind_front() and wrapped in std::function, per the <10 line lambda coding standard in docs/COMMON_ERRORS.md. Also take the D-Bus error_code callback parameter by const reference instead of a mutable reference, per review comment. Tested: - Ran `bmcweb loglevel debug` on a running BMC against the live bmcweb daemon's xyz.openbmc_project.bmcweb SetLogLevel D-Bus method. The async_method_call completed through the new afterSetLogLevel() callback, printed "logging level changed to: DEBUG", and the CLI process exited 0. - Confirmed the level change actually took effect on the daemon: a subsequent Redfish GET request produced verbose DEBUG-level trace lines in `journalctl -u bmcweb` (e.g. http2_connection.hpp, http_body.hpp entries) that are suppressed at the default INFO level. - Redfish Service Validator passed with 0 failures (5822 Pass / 353 Warn / 0 Fail). Change-Id: I7ee42c25996cc6da98eab4af4535de0f95e110cd Signed-off-by: Yuvakumar Selvamani <yuvakumars@ami.com>
2026-07-02Allow setting Mozilla modernEd Tanous1-21/+57
Mozilla publishes recommendations for TLS cipher suites to support. For many years bmcweb selected "intermediate" because of compatibility with clients that didn't yet support TLS1.3. This commit adds the ability to use the Mozilla modern recommendations, and disable TLS1.2 support through a new meson option, tls-profile. Tested: Loaded on qemu, and verified with testssl.sh[1] that parameters were applied. [1] https://github.com/testssl/testssl.sh Change-Id: I38e915b3943b5dbe5fb31e54eb3ebda9bbaeb811 Signed-off-by: Ed Tanous <etanous@nvidia.com>
2026-07-01Flag long lambdasEd Tanous3-0/+5
Long lambdas have been documented as an anti-pattern for some time.[1] Despite this being generally understood, bmcweb has a long ways to go cleaning these up, and routinely code is submitted in violation of this anti-pattern. Invent an ast-grep rule that can identify when new examples of this anti-pattern are added, and ignore the existing 200+ examples that are in the codebase already using ast-grep ignore. These flags will give us something to search for as we clean this up, and will help to prevent new instances from being added unintentionally. [1] https://github.com/openbmc/docs/blob/master/anti-patterns.md#very-long-lambda-callbacks Tested: Comment only change. ast-grep passes. Manually removing an ast-grep ignore flag shows as a failure in ast-grep scan Change-Id: I77d634a393884969f184d2c39c02cc08288d5a29 Signed-off-by: Ed Tanous <etanous@nvidia.com>
2026-06-12Generate 64 bit serial numbersEd Tanous1-1/+4
Even though the certificate is self signed, we should pass as many certificate tests as possible. testssl.sh prints ``` Serial 4B32D4F0 NOT ok: length should be >= 64 bits entropy (is: 4 bytes) ``` On our default certificate. This is relatively easy to fix. Change-Id: Ib1eb07b637ebf49ecf954b3d98ced9e9ef0f5a34 Signed-off-by: Ed Tanous <etanous@nvidia.com>
2026-06-12OpenSSL cleanupEd Tanous1-102/+15
Continue moving OpenSSL into reusable RAII classes that can be used in unit tests and other places. This is slightly more code, but as we're adding unit tests, it allows reuse between unit tests rather than writing C directly. It also encapsulates the complexity of parsing openssl output (usually in bytes) into standard types (string) that can be compared/modified. Functionally this adds two new classes to the "wrappers" functions, OpenSSLSSLCtx and OpenSSLSSL, which each wrap SSL_CTX and SSL objects respectively from openssl. These are rough approximations of the boost equivalents. Change-Id: Id87ac4ccde88890bd70861deffdb256188ec0e39 Signed-off-by: Ed Tanous <etanous@nvidia.com>
2026-06-08account_service: invalidate sessions when account is disabledChandramohan Harkude1-1/+1
PATCH /redfish/v1/AccountService/Accounts/ with {"Enabled":false} flipped UserEnabled on D-Bus but left every active X-Auth-Token session for that user fully usable. Subsequent token-authenticated requests continued to succeed (200 OK) until the token's natural expiry, even though Basic auth for the same account was correctly rejected (401). DELETE on the same resource does not have this problem because removing the user object emits InterfacesRemoved, and bmcweb::onUserRemoved (in include/user_monitor.hpp) handles that signal by calling removeSessionsByUsername. Add onUserPropertiesChanged() in include/user_monitor.hpp that drops the user's sessions via SessionStore::removeSessionsByUsername() when User.Attributes.UserEnabled transitions to false. This handles disable of user both from IPMI and Redfish Tested : ``` Create new user curl -k -u ${USER}:${PASSWD} -X POST https://127.0.0.1:2443/redfish/v1/AccountService/Accounts -d '{ UserName:test_admin, Password:Shahapur#13!Shahapur, RoleId:Administrator, Enabled:true}' { "@Message.ExtendedInfo": [ { "@odata.type": "#Message.v1_1_1.Message", "Message": "The resource was created successfully.", "MessageArgs": [], "MessageId": "Base.1.19.Created", "MessageSeverity": "OK", "Resolution": "None." } ] } Create a-auth-token curl --insecure -X POST -D headers.txt https://127.0.0.1:2443/redfish/v1/SessionService/Sessions -d '{"UserName":"test_admin", "Password":"Shahapur#13!Shahapur"}' { "@odata.id": "/redfish/v1/SessionService/Sessions/YLMzEtANWr", "@odata.type": "#Session.v1_7_0.Session", "ClientOriginIPAddress": "10.0.2.2", "Description": "Manager User Session", "Id": "YLMzEtANWr", "Name": "User Session", "Roles": [ "Administrator" ], "UserName": "test_admin" } $ cat headers.txt HTTP/2 201 allow: GET, HEAD, POST odata-version: 4.0 x-auth-token: VcufgTshiDjEn8HbGh31 location: /redfish/v1/SessionService/Sessions/YLMzEtANWr strict-transport-security: max-age=31536000; includeSubdomains pragma: no-cache cache-control: no-store, max-age=0 x-content-type-options: nosniff content-type: application/json date: Wed, 06 May 2026 12:45:18 GMT content-length: 305 // Test RF request with token curl -k -H 'x-auth-token:VcufgTshiDjEn8HbGh31' https://127.0.0.1:2443/redfish/v1/AccountService/Accounts { "@odata.id": "/redfish/v1/AccountService/Accounts", "@odata.type": "#ManagerAccountCollection.ManagerAccountCollection", "Description": "BMC User Accounts", "Members": [ { "@odata.id": "/redfish/v1/AccountService/Accounts/test_admin" }, { "@odata.id": "/redfish/v1/AccountService/Accounts/root" } ], "Members@odata.count": 2, "Name": "Accounts Collection" } // Disable the user curl -k -u root:0penBmc https://127.0.0.1:2443/redfish/v1/AccountService/Accounts/test_admin -X PATCH -d '{"Enabled":false}' 204 // Try to use the Tokens curl -k -H 'x-auth-token:VcufgTshiDjEn8HbGh31' https://127.0.0.1:2443/redfish/v1/AccountService/Accounts 401 ``` Change-Id: I3246d3f5ec7db405c9c186a8672a9fed18259249 Signed-off-by: Chandramohan Harkude <chandramohan.harkude@gmail.com>
2026-04-30conversion cast to fix buildAlexander Hansen1-1/+2
The compile error was also mentioned here: [1] ``` | ../sources/bmcweb-1.0+git/src/ssl_key_handler.cpp:293:61: error: conversion from 'std::chrono::duration<long long int>::rep' {aka 'long long int'} to 'long int' may change value [-Werror=conversion] | 293 | X509_gmtime_adj(X509_getm_notAfter(x509), duration.count()); | | ~~~~~~~~~~~~~~^~ | cc1plus: all warnings being treated as errors ``` The relevant function signature only accepts 'long' anyways, so assuming that is what the authors intention was. ``` ASN1_TIME *X509_gmtime_adj(ASN1_TIME *s, long adj); ``` Looking at the value of `duration.count()` it is `315569520` which is representable by a 32-bit signed integer type. References: [1] https://gerrit.openbmc.org/c/openbmc/openbmc/+/89780/comments/d1fbedfb_3eca650e Change-Id: Idecb18acc4c7862d0ca56efd090736cacbdd8164 Signed-off-by: Alexander Hansen <alexander.hansen@9elements.com>
2026-04-27Add more unit tests for UPN functionalityIgor Kanyuka1-1/+1
Current unit tests only covers happy path. Add more unit tests before changing the code. Tested: unit tests Change-Id: Ibba5dbbc1457b59670d5d8f3c828fa9ca112f88c Signed-off-by: Igor Kanyuka <ifelmail@gmail.com>
2026-04-27RAII OpenSSLEd Tanous1-202/+205
bmcweb openssl usage is a mess. Start cleaning it up. 1. Make RAII objects for any held memory. 2. Move methods from hostname monitor into the ssl namespace, so not all compile units need to pull in openssl headers 3. Move methods to static where functions can be encapsulated. Because we're now testing openssl, we need to register memory init so that the sanitizers don't cause issues when mallocing from non bootstrapped openssl binaries. Openssl provides a handle for this, so use it in those unit tests. Tested: Unit tests pass. bmcweb launches and can open ssl with curl as it did previously. Change-Id: If0340692d2c56a6c45bb8d661d654a4b58ff3d2c Signed-off-by: Ed Tanous <etanous@nvidia.com>
2026-04-16Fix certificate error handlingPrabha Veerubhotla1-0/+31
Certificate operations were returning generic HTTP 500 errors instead of proper Redfish-compliant error codes. This commit adds central io_error handling in dbus::utility::getSubTreePaths() and related functions, and updates certificate POST operations to use handleError() for proper HTTP status codes. This prevents HTTP 500 errors for empty certificate collections (now returns HTTP 200 with empty array[]) and returns proper HTTP 400/404 errors for invalid certificates instead of generic 500. Tested: - Empty certificate collections return HTTP 200 with [] - Invalid certificates return HTTP 400 instead of 500 Change-Id: I737ea439bee618d2e7b36dc75be8e10c58278441 Signed-off-by: Prabha Veerubhotla <vvlprabha@gmail.com>
2026-04-15sdbusplus: use shorter type aliasesPatrick Williams1-5/+5
The sdbusplus headers provide shortened aliases for many types. Switch to using them to provide better code clarity and shorter lines. Possible replacements are for: * bus_t * exception_t * manager_t * match_t * message_t * object_t * slot_t * object_path Change-Id: Iace20f9ad26e8d9dc234979e7a4087d599da2641 Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
2026-03-19Add TLS session resumption support to mTLSIgor Kanyuka1-36/+58
TLS session resumption allows to bypass full TLS handshake in subsequent connections, it's enabled in OpenSSL, so clients that support it use it. One of the optimizations is, the client passes Session ID in subsequent request and does not pass certificates. Since client certificate is not passed, the callback that populates user session out of the certificate is not called, and as result, auth fails for requests sents in subsequent connections. This change enables session ID in memory cache, lookup of the certificate in the cache by the session ID received from the client and constructing user session out of it for subsequent connections. The cache is stored in RAM [1]. According to Nginx doc [2], size of one session is about 250 bytes. If sessions use mTLS, they will also contain a cert which is typically up 2kb. A client establishes connections as part of a session, so a session can be associated with multiple connections. In the worst case, when many clients establish a single connection at a time, or a client always uses a new session for every established connection, there will be number of session entries in the cache equals to the number of connections. While OpenSSL limits cache size to SSL_SESSION_CACHE_MAX_SIZE_DEFAULT which is 20480 [3], OpenBMC limits number of established connections to 200 [4], so in the worst case, memory usage will be ~50kb for non mTLS clients, and ~440kb for mTLS clients. Typically, when there are just 2-3 clients connected, even if them maintain multiple connections within their sessions, the cache size will be less than 10kb for mTLS. To prevent high memory usage by the cache, the change sets cache size to 100 entries. Expired sessions are automatically removed on every 255th session [5]. Tested: Deployed on one of our envs and ran client that quickly sends multiple requests to the BMC (so the client created several connections), and make sure the 401 auth problem had been observed before gone. Also, made sure BMCWeb logged debug messages about existing session detection. Ran tests from the openbmc-test-automation repository, esp related to certificate and user management. They do session auth and not mTLS/multi-connection, so they could not detect/confirm the problem is fixed, but they confirm the change does not break the primary use case. [1] https://docs.openssl.org/3.6/man3/SSL_CTX_set_session_cache_mode/#notes [2] https://nginx.org/en/docs/http/ngx_http_ssl_module.html#ssl_session_cache [3] https://github.com/openssl/openssl/blob/5869303daaecf037f0d00dc33a00f9bdc1e71f2f/include/openssl/ssl.h.in#L670 [4] https://github.com/openbmc/bmcweb/blob/master/http/http_connection.hpp#L219C13-L219C28 [5] https://docs.openssl.org/3.6/man3/SSL_CTX_flush_sessions/#notes Change-Id: Ia94d1e323cd464cc7ca5b0f9c7d6a76e4c780e9a Signed-off-by: Igor Kanyuka <ifelmail@gmail.com>
2026-02-24Fix spelling mistakes using codespellGeorge Liu1-1/+1
Signed-off-by: George Liu <liuxiwei@ieisystem.com> Change-Id: If170e53077bc150d0062cd441394daea71f842b1
2026-01-30Remove usages of nlohmann::json::begin()Ed Tanous1-9/+21
nlohmann::json::begin() throws an uncaught exception. Tested: Redfish service validator passes. Signed-off-by: Ed Tanous <ed@tanous.net> Change-Id: I08244b0787cd4d6e592b0731196490a5160aba62
2025-12-18Implement modernize-use-rangesEd Tanous1-4/+3
This tidy check can transform code to use std::ranges. Enable the check, apply the fixes it proposes. Tested: Redfish service validator passes in qemu Change-Id: I3f21b27d3d30277f71b9c8a2c584a22bc16865e9 Signed-off-by: Ed Tanous <etanous@nvidia.com>
2025-11-22Fix bmcweb daemon loglevel as in meson optMyung Bae1-2/+1
The commit[1] caused to set the loglevel to INFO even for the daemon. This commit is to use the loglevel as defined in meson.option. Tested: - Run bmcweb daemon and check the log entries - Try 'bmcweb loglevel <lvl>' [1] https://gerrit.openbmc.org/c/openbmc/bmcweb/+/84056 Change-Id: Ic83ff63796cef5bc6324882921b66fc0a0965de1 Signed-off-by: Myung Bae <myungbae@us.ibm.com>
2025-10-23Remove deprecated openssl callEd Tanous1-7/+0
Openssl docs show this as deprecated in OpenSSL 1.1.0, which came out in 2019. It is now just automatically set. OpenSSL =>1.0.2 is deprecated, which would be the only OpenSSL to use this. OpenBMC is using 3.0.8 OpenSSL, so this can be removed. [1] https://manpages.debian.org/testing/libssl-doc/SSL_CTX_set_ecdh_auto.3ssl.en.html Change-Id: I0aab0b00e39dc5cbbf9c6facddf338bd99c4ae67 Signed-off-by: Ed Tanous <etanous@nvidia.com>
2025-10-23Break out x509 generationEd Tanous1-87/+89
This function is a little long, and deeply nested which makes the cleanup a little confusing. Break out one method into its own function. Tested: bmcweb starts, and certificates generate correctly. Change-Id: I315c172ae17e1efa9ba049c4fb60a9c369c6415b Signed-off-by: Ed Tanous <etanous@nvidia.com>
2025-10-21Add back include cleanerEd Tanous1-1/+0
Include cleaner helps the code review process. Add it back, by ignoring some of the more recent boost headers. Change-Id: I6eddd0e67cd9f469c93fbb344cc1ab46231e450f Signed-off-by: Ed Tanous <etanous@nvidia.com>
2025-10-03Remove getNthStringFromPath functionEd Tanous1-27/+0
This utility function is being removed for several reasons. First, it does not verify the full string on URIs and paths, so things like /foo/bar/baz/valid_id would still pass this check. Second, it is used for both URIs and dbus paths, both of which we have better utility functions these days respectively, boost::url for urls and sdbusplus::message::object_path for dbus paths. Neither of the two is escaped properly when this function is used. Therefore, remove it and replace it with the appropriate alternatives. The existing URI functions were found to not accept fragments (given they are rarely used in PATCH). Add support for fragments to cover the getNthStringFromPath use cases. Tested: Redfish service validator passes. Change-Id: Ibc6755ad69397123d7fef0e0b764042bbb48888b Signed-off-by: Ed Tanous <etanous@nvidia.com>
2025-10-02Clean up CLI namingEd Tanous4-40/+40
Now that all applications run through one CLI, names like run() don't make a lot of sense. Update names to match the new reality, make bmcweb with no arguments launch the webserver once again. Tested: bmcweb boots. Change-Id: I011b57507872a9518a9c470b58779805504c7293 Signed-off-by: Ed Tanous <etanous@nvidia.com>
2025-10-01Fix lifetime issue and shutdown issueEd Tanous1-3/+5
If bmcweb isn't running, the existing code stalls because io.stop() is never called. Fix that, as well as make loglevel capture by value in the lambda. Tested: Inspection only. Change-Id: I61c5ea323d58b984c5b7356a6f2637d2a953a0b1 Signed-off-by: Ed Tanous <etanous@nvidia.com>
2025-09-18merge binaries bmcweb and bmcwebdAlexander Hansen3-11/+39
Solution to reduce compressed rofs size. Conclusion: The compiler is better at reducing binary size than the rofs compression is at deduplicating sections of already compiled binaries, in the case of bmcweb. What's been changed? `bmcweb` and `bmcwebd` have been merged into `bmcweb`. The webserver can be started with `bmcweb daemon`. Commands used to check size ``` wc -c build/s8030/tmp/work/*-openbmc-linux-gnueabi/obmc-phosphor-image/1.0/obmc-phosphor-image-1.0/static/image-rofs wc -c build/s8030/tmp/deploy/images/s8030/image-rofs xz -c build/s8030/tmp/work/*-openbmc-linux-gnueabi/obmc-phosphor-image/1.0/rootfs/bin/bmcweb | wc -c xz -c build/s8030/tmp/work/*-openbmc-linux-gnueabi/obmc-phosphor-image/1.0/rootfs/usr/libexec/bmcwebd | wc -c ``` Base commit used for testing: `2169e896448fac1b59c57516b381492e4b2161c7` Results: Before patch: ``` image-rofs compressed size: 25526272 build/s8030/tmp/work/s8030-openbmc-linux-gnueabi/obmc-phosphor-image/1.0/obmc-phosphor-image-1.0/static/image-rofs rootfs 25526272 build/s8030/tmp/deploy/images/s8030/image-rofs bmcweb cli 95424 bmcwebd 1016004 ``` After patch: ``` image-rofs compressed size: 25477120 build/s8030/tmp/work/s8030-openbmc-linux-gnueabi/obmc-phosphor-image/1.0/obmc-phosphor-image-1.0/static/image-rofs rootfs 25477120 build/s8030/tmp/deploy/images/s8030/image-rofs bmcweb cli 96 bmcwebd 1059556 ``` Calculating the difference in compressed rofs 25526272 - 25477120 = 49152 which is around 0.2% in terms of the total image but around 4.6% in terms of bmcwebd binary. Tested: on yosemite4 qemu `bmcweb` cli interactions work as before. ``` root@yosemite4:~# bmcweb --help BMCWeb CLI Usage: bmcweb [OPTIONS] SUBCOMMAND Options: -h,--help Print this help message and exit Subcommands: loglevel Set bmcweb log level daemon Run webserver root@yosemite4:~# bmcweb loglevel info <6>[webserver_cli.cpp:97] logging level changed to: INFO root@yosemite4:~# bmcweb loglevel level is required Run with --help for more information. root@yosemite4:~# bmcweb loglevel debug <6>[webserver_cli.cpp:97] logging level changed to: DEBUG ``` systemd service still working ``` root@yosemite4:~# systemctl status bmcweb ● bmcweb.service - Start bmcweb server Loaded: loaded (/usr/lib/systemd/system/bmcweb.service; enabled; preset: enabled) Active: active (running) since Thu 2025-04-03 13:35:45 PDT; 5 months 15 days ago ``` Change-Id: Ib5dde568ac1c12c5414294ed96404c6a69417424 Signed-off-by: Alexander Hansen <alexander.hansen@9elements.com>
2025-08-26Fix includesEd Tanous1-0/+1
Our includes haven't been enforced by tidy in a while. Run the script, check in the result, minus the false positives. Change-Id: I6a6da26f5ba5082d9b4aa17cdc9f55ebd8cd41a6 Signed-off-by: Ed Tanous <etanous@nvidia.com>
2025-08-12Fix handling of ssl_key_handler for WebUIMyung Bae1-1/+1
The previous commit 90cd2e1 [1] causes WebUI to fail to load and connect. It is because a global static var (`hasWebuiRoute`) is instantiated per compile unit and it ends up causing the inconsistency of the value of it. Tested: - Verify WebUI to load successful - Redfish Service Validator passes [1] https://github.com/openbmc/bmcweb/commit/90cd2e1d2e2228b0c575c9a3b6b2dc75eac9eb68 Change-Id: I09c3a9a831528e25c09299b0ee15993974d94d88 Signed-off-by: Myung Bae <myungbae@us.ibm.com>
2025-07-09Move http2 out of experimentalEd Tanous1-1/+1
Http2 support in bmcweb has been relatively stable for a while. The http2 implementation passes all known Redfish tests (some of which require ported to httpx to support http2), the UI loads, and so far as the project is concerned, is a complete improvement over the existing http1 stack. This commit removes the experimental classification from http2, and declares it ready for production use, while enabling it by default. note, that enabling this by default only makes the server advertise that http2 is available. Http2 must still be supported by the client to enable ALPN negotiation, so existing http1 clients that only support http1 will continue to function as they did before. Tested: Enabled http option and saw http2 advertised, http2 now takes effect. Change-Id: I92843a3afc532f0b2a64904bb872e5d84a1a54fe Signed-off-by: Ed Tanous <etanous@nvidia.com>
2025-06-27Rearrange featuresEd Tanous1-2/+2
The backends are different things compared to generic code. Today, these are all included in the /include folder, but it's not very clear what options control which backends, or how things map together. This also means that we can't separate ownership between the various companies. This commit is a proposal to try to create a features folder, separated by the code for the various backends, to make interacting with this easier. It takes the form features/<option name>/files.hpp features/<option name>/files_test.hpp Note, redfish-core was already at top level, and contains lots of code, so to prevent lots of conflicts, it's simply symlinked into that folder to make clear that it is a backend, but not to move the implementation and cause code conflicts. Tested: Unit tests pass. Code compiles. Change-Id: Idcc80ffcfd99c876734ee41d53f894ca5583fed5 Signed-off-by: Ed Tanous <etanous@nvidia.com>
2025-06-06ssl_key_handler: enable verify_peer for Meta TLS modeEd Tanous1-11/+27
Meta does not use TLSStrict, due to wanting optional password authentication, but does need mTLS support. 463a0e3 broke this functionality in order to fix asking for client certificates on the webui side. Revert to the old behavior only if the webui is not installed. Signed-off-by: Patrick Williams <patrick@stwcx.xyz> Signed-off-by: Ed Tanous <etanous@nvidia.com> Change-Id: Iae2e62faa5e8341c0422ab0521dea340d4e927b2
2025-06-04Remove implicit conversionsEd Tanous1-1/+6
Since 2020, nlohmann has recognized that implicit conversions to and from json are an issue. Many bugs have been caused at both development time and runtime due to unexpected implicit conversions from json to std::string/int/bool. This commit disables implicit conversions using JSON_USE_IMPLICIT_CONVERSIONS [1]. This option will become the default in the future. That comment was written 3 years ago at this point, so we should prepare. Tested: Redfish service validator passes. [1] https://json.nlohmann.me/api/macros/json_use_implicit_conversions/ Change-Id: Id6cc47b9bbf8889e4777fd6d77ec992f3139962c Signed-off-by: Ed Tanous <etanous@nvidia.com>
2025-05-15Fix inconsistent persistent subscription loadMyung Bae1-0/+3
When BMC reboots or bmcweb restarts, the persistent subscriptions may not be loaded properly but they may still be in the file. Later on if BMC reboots or bmcweb restarts, those unloaded subscriptions may potentially and unexpectedly cause the reload into the active subscriptions. The key cause is due to the compiler evaluation order for the function arguments where the last argument is evaluated and pushed into the stack first. As the result, the first argument `newSub->id` may already be invalid after the last argument `std::make_shared<>(std::move(*newSub))` is evaluated and pushed into the parameter stack [1]. This may cause the failure of `subscriptionsConfigMap.emplace()` and results in the missing instantiation of the persistent subscriptions. Tested: - Create many subscriptions - GET subscriptions ``` curl -k -X GET https://${bmc}/redfish/v1/EventService/Subscriptions { "@odata.id": "/redfish/v1/EventService/Subscriptions", "@odata.type": "#EventDestinationCollection.EventDestinationCollection", "Members": [ { "@odata.id": "/redfish/v1/EventService/Subscriptions/1187258741" }, ... { "@odata.id": "/redfish/v1/EventService/Subscriptions/949306789" } ], "Members@odata.count": 6, "Name": "Event Destination Collections" } ``` - Restart bmcweb - GET subscriptions again and check whether they are the same. - Sometimes, none or only a few may be instantiated like ``` curl -k -X GET https://${bmc}/redfish/v1/EventService/Subscriptions { "@odata.id": "/redfish/v1/EventService/Subscriptions", "@odata.type": "#EventDestinationCollection.EventDestinationCollection", "Members": [ { "@odata.id": "/redfish/v1/EventService/Subscriptions/1187258741" } ], "Members@odata.count": 1, "Name": "Event Destination Collections" } ``` - However, the file `/home/root/bmcweb_persistent_data.json` still has the old entries. - Also verify Redfish Service Validator to pass [1] https://github.com/openbmc/bmcweb/blob/0c814aa604b36cff01b495f9c335f981c7be83be/include/persistent_data.hpp#L184 Change-Id: Ia8a3c1bd3d4f4e479b599077ba8f26e47f8d22ef Signed-off-by: Myung Bae <myungbae@us.ibm.com>
2025-04-29Fix more movesEd Tanous1-10/+10
This commit is fixing coverity issues reported for copy in stead of move. Tested: redfish service validator passes Change-Id: I97e755830f28390e7c4bfaba6f3f947898a21423 Signed-off-by: Ed Tanous <ed@tanous.net>
2025-04-14ssl: Switch to use_certificate_chain for certificate loadingBen Peled1-1/+1
Replace use_certificate with use_certificate_chain to properly handle both single certificates and certificate chains. This allows loading and sending the complete certificate chain during TLS handshake, improving client validation. Tested with generate_user_auth.py Change-Id: I8ef1665307ee2e401901a662ac9ee6df7b50937d Signed-off-by: Ben Peled <bpeled@nvidia.com>
2025-04-10Add async_method_call to utilityEd Tanous1-9/+9
Adding async_method_call in dbus utility gives us a place where we can intercept method call requests from dbus to potentially add logging/caching. An example of logging is in the later commit: https://gerrit.openbmc.org/c/openbmc/bmcweb/+/78265/ We already do this for setProperty, this moves the method calls to follow a similar pattern. Tested: Redfish service validator passes. Change-Id: I6d2c96e2b6b6a023ed2138106a55faebca161592 Signed-off-by: Ed Tanous <etanous@nvidia.com>
2025-04-03OEM Route Handling Infrastructurerohitpai1-1/+1
Goal of the MR is to provide infrastructure support in bmcweb to manage the OEM fragment handling separately. OEM schema are vendor defined and per DMTF resource we could have multiple vendor defined OEM schema to be enabled. The feature allows registration of route handler per schema per OEM namespace. Example ``` REDFISH_SUB_ROUTE<"/redfish/v1/Managers/<str>/#/Oem/OpenBmc">(service, HttpVerb::Get)(oemOpenBmcCallback); REDFISH_SUB_ROUTE<"/redfish/v1/Managers/<str>/#/Oem/Nvidia">(service, HttpVerb::Get)(oemNidiaCallback); ``` We can have separate vendor defined route handlers per resource. Each of these route handlers can populate their own vendor specific OEM data. The OEM code can be better organized and enabled/disabled as per the platform needs. The current MR has the code changes related to handling GET requests alone. The feature only supports requests where the response payload is JSON. Tests - All UT cases passes - New UT added for RF OEM router passes - Service Validator passes on qemu - GET Response on Manager/bmc resource contains the OEM fragment ``` curl -c cjar -b cjar -k -X GET https://127.0.0.1:2443/redfish/v1/Managers/bmc { "@odata.id": "/redfish/v1/Managers/bmc", "@odata.type": "#Manager.v1_14_0.Manager", "Oem": { "OpenBmc": { "@odata.id": "/redfish/v1/Managers/bmc#/Oem/OpenBmc", "@odata.type": "#OpenBMCManager.v1_0_0.Manager", "Certificates": { "@odata.id": "/redfish/v1/Managers/bmc/Truststore/Certificates" } } }, "UUID": "40575e98-90d7-4c10-9eb5-8d8a7156c9b9" } ``` Change-Id: Ic82aa5fe760eda31e2792fbdfb6884ac3ea613dc Signed-off-by: Rohit PAI <rohitpai77@gmail.com>
2025-03-17Add support for systemd service watchdogrohitpai1-0/+3
Systemd has support for enabling service level watchdog. The MR enables this support for bmcweb daemon. Request for watchdog monitor from systemd is added in bmcweb.service.in. From the event loop a timer is registered to kick the watchdog periodically The default watchdog timeout is set at 120 seconds and the timer is set to kick it at a quarter of the interval (every 30 seconds). This timeout is set somewhat arbitrarily based on the longest blocking call that could occur and still give a valid HTTP response. Suspect lower values could work equally as well. Benefits of Service Watchdog - Bmcweb route handlers should not make any blocking IO calls which block the event loop for considerable amount of time and slowdown the response of other URI requests in the queue. Watchdog can help to detect such issues. - Watchdog can help restart the service if any route handler code has uncaught bugs resulting from system API errors (this is in theory, currently we don't have any use case). Tested 1. UT is passing 2. Service validator is passing 3. Fw upgrade POST requests are working Change-Id: If62397d8836c942fdcbc0618810fe82a8b248df8 Signed-off-by: rohitpai <ropai@nvidia.com> Signed-off-by: Ed Tanous <etanous@nvidia.com>
2025-02-13Break out dbus utilities into compile unitEd Tanous1-0/+252
ClangBuildAnalyzer shows that each of these dbus calls is relatively expensive to compile, so put them in their own compile unit so they can be compiled separately. Tested: Redfish service validator passes Change-Id: Ia383611182d8bc93c125248c4196898cb51fd807 Signed-off-by: Ed Tanous <etanous@nvidia.com>
2025-02-10Enable HTTP additional socketsEd Tanous1-9/+7
This commit attempts to add the concept of an SSL detector from beast, and add the capability into bmcweb. This allows directing multiple socket files to the bmcweb instance, and bmcweb will automatically sort out whether or not they're SSL, and give the correct response. This allows users to plug in erroneous urls like "https://mybmc:80" and they will forward and work correctly. Some key design points: The HTTP side of bmcweb implements the exact same http headers as the HTTPS side, with the exception of HSTS, which is explicitly disallowed. This is for consistency and security. The above allows bmcweb builds to "select" the appropriate security posture (http, https, or both) for a given channel using the FileDescriptorName field within a socket file. Items ending in: both: Will support both HTTPS and HTTP redirect to HTTPS https: Will support HTTPS only http: will support HTTP only Given the flexibility in bind statements, this allows administrators to support essentially any security posture they like. The openbmc defaults are: HTTPS + Redirect on both ports 443 and port 80 if http-redirect is enabled And HTTPS only if http-redirect is disabled. This commit adds the following meson options that each take an array of strings, indexex on the port. additional-ports Adds additional ports that bmcweb should listen to. This is always required when adding new ports. additional-protocol Specifies 'http', 'https', or 'both' for whether or not tls is enfoced on this socket. 'both' allows bmcweb to detect whether a user has specified tls or not on a given connection and give the correct response. additional-bind-to-device Accepts values that fill the SO_BINDTODEVICE flag in systemd/linux, and allows binding to a specific device additional-auth Accepts values of 'auth' or 'noauth' that determines whether this socket should apply the normal authentication routines, or treat the socket as unauthenticated. Tested: Previous commits ran the below tests. Ran the server with options enabled. Tried: ``` curl -vvvv --insecure --user root:0penBmc http://192.168.7.2/redfish/v1/Managers/bmc * Trying 192.168.7.2:80... * Connected to 192.168.7.2 (192.168.7.2) port 80 (#0) * Server auth using Basic with user 'root' > GET /redfish/v1/Managers/bmc HTTP/1.1 > Host: 192.168.7.2 > Authorization: Basic cm9vdDowcGVuQm1j > User-Agent: curl/7.72.0 > Accept: */* > * Mark bundle as not supporting multiuse < HTTP/1.1 301 Moved Permanently < Location: https://192.168.7.2 < X-Frame-Options: DENY < Pragma: no-cache < Cache-Control: no-Store,no-Cache < X-XSS-Protection: 1; mode=block < X-Content-Type-Options: nosniff < Content-Security-Policy: default-src 'none'; img-src 'self' data:; font-src 'self'; style-src 'self'; script-src 'self'; connect-src 'self' wss: < Date: Fri, 08 Jan 2021 01:43:49 GMT < Connection: close < Content-Length: 0 < * Closing connection 0 ``` Observe above: webserver returned 301 redirect. webserver returned the appropriate security headers webserver immediately closed the connection. The same test above over https:// returns the values as expected Loaded the webui to test static file hosting. Webui logs in and works as expected. Used the scripts/websocket_test.py to verify that websockets work. Sensors report as expected. Change-Id: Ib5733bbe5473fed6e0e27c56cdead0bffedf2993 Signed-off-by: Ed Tanous <ed@tanous.net>
2025-02-04clang-format: update latest spec and reformatPatrick Williams1-2/+2
Copy the latest format file from the docs repository and apply. Change-Id: I2f0b9d0fb6e01ed36a2f34c750ba52de3b6d15d1 Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
2025-01-31Move io context to singletonEd Tanous1-6/+7
The way we pass around io contexts is somewhat odd. Boost maintainers in slack recommended that we just have a method that returns an io context, and from there we can control this (context link lost years ago). The new version of clang claims the singleton pattern of passing in an io_context pattern is a potential nullptr dereference. It's technically correct, as calling the singleton without immediately initializing the io context will lead to a crash. This commit implements what the boost maintainers suggested, having a single method that returns "the context" that should be used. This also helps to maintain isolation, as some pieces are no longer tied directly to dbus to get their reactor. Tested: WIP Change-Id: Ifaa11335ae00a3d092ecfdfb26a38380227e8576 Signed-off-by: Ed Tanous <etanous@nvidia.com>
2025-01-20Use SPDX identifiersEd Tanous10-0/+20
SPDX identifiers are simpler, and reduce the amount of cruft we have in code files. They are recommended by linux foundation, and therefore we should do as they allow. This patchset does not intend to modify any intent on any existing copyrights or licenses, only to standardize their inclusion. [1] https://www.linuxfoundation.org/blog/blog/copyright-notices-in-open-source-software-projects Change-Id: I935c7c0156caa78fc368c929cebd0f068031e830 Signed-off-by: Ed Tanous <etanous@nvidia.com>
2024-12-16Fix boost UUID build issueEd Tanous1-1/+1
Boost seems to have changed to not directly expose basic_random_generator. This results in an error. ``` ../src/ossl_random.cpp:15:1: error: included header random_generator.hpp is not used directly [misc-include-cleaner,-warnings-as-errors] ``` Tested: Code builds. #include only change. Change-Id: Ib17a3520b8207e6e4de5aa7a3807bd6cec6d4e25 Signed-off-by: Ed Tanous <etanous@nvidia.com>
2024-11-27event service: dbus log: enable event subscriptionAlexander Hansen1-4/+3
enable the event subscriptions /redfish/v1/EventService/Subscriptions/ to work for the dbus event log. So if you are enabling redfish-dbus-log option, event subscriptions should work similar to when this option is disabled, with one difference: - 'MessageArgs' property is currently not implemented and cannot be found in the returned json. Tested: - Using Redfish Event Listener, test subscriptions and eventing. - Manual Test below with the Redfish Event Listener: 1. Created a maximal Event Log Subscription redfish { "@odata.id": "/redfish/v1/EventService/Subscriptions/2023893979", "@odata.type": "#EventDestination.v1_8_0.EventDestination", "Context": "EventLogSubscription", "DeliveryRetryPolicy": "TerminateAfterRetries", "Destination": "http://${ip}:5000/event-receiver", "EventFormatType": "Event", "HttpHeaders": [], "Id": "2023893979", "MessageIds": [], "MetricReportDefinitions": [], "Name": "Event Destination 2023893979", "Protocol": "Redfish", "RegistryPrefixes": [], "ResourceTypes": [], "SubscriptionType": "RedfishEvent", "VerifyCertificate": true } which matches on all registries and all message ids. 2. created a new phosphor-logging entry busctl call xyz.openbmc_project.Logging \ /xyz/openbmc_project/logging \ xyz.openbmc_project.Logging.Create \ Create 'ssa{ss}' \ OpenBMC.0.1.PowerButtonPressed \ xyz.openbmc_project.Logging.Entry.Level.Error 0 3. bmcweb picks up this new entry via the dbus match, this can be verified by putting bmcweb in debug logging mode. 4. the event log entry makes it through the filtering code 5. the POST request is sent to the subscribed server as expected, and contains the same properties as with the file-based backend. Change-Id: I122e1121389f72e67a998706aeadd052ae607d60 Signed-off-by: Alexander Hansen <alexander.hansen@9elements.com>
2024-11-27Break out Dbus events into classEd Tanous1-17/+4
EventServiceManager is already too large. Implement the TODO from run that these should be classes, and fix the issue where events are being registered on startup, not on a subscription being created. To accomplish this, this patch takes global state and breaks them out into RAII classes from EventServiceManager, one for monitoring DBus matches, and one for monitoring filesystem log events using inotify. Each of these connect to static methods on EventService that can send the relevant events to the user. Fundamentally, no code within the two new classes is changed, and the only changes to event service are made to support creation and destruction of the RAII classes. There are a number of call sites, like cacheRedfishLogFile, that are obsoleted when the class is raii. The file will be re-cached on creation. Tested: WIP No TelemetryService tests exist in Redfish. Change-Id: Ibc91cd1496edf4a080e2d60bfc1a32e00a6c74b8 Signed-off-by: Ed Tanous <etanous@nvidia.com>
2024-11-23Break out filesystem watcher into separate fileEd Tanous1-2/+3
EventServiceManager is very large. Break out two of the functions, and the global variables into a separate compile unit. Code is copied as-is, with no improvements made in this patch. Tested: At end of series. Change-Id: I89a3605885e5bafa86a6083f1ff8c5db3bb8daf9 Signed-off-by: Ed Tanous <etanous@nvidia.com>
2024-10-24Explicitly set verify_noneEd Tanous1-9/+10
As reported, there are cases where a valid certificate isn't present, but a browser still prompts for an MTLS cert. Fix that by explicitly setting verify_none if strict tls isn't enabled. Unclear what impacts this will have elsewhere: Tested (not yet done on this patch): with a self-signed certificate, logging into chrome no longer prompts the certificate screen. Change-Id: Iaf7d25fec15ad547a6c741c9410995e19ba22016 Signed-off-by: Ed Tanous <etanous@nvidia.com>
2024-09-09Improve bmcweb CLI appAushim Nagarkatti1-5/+43
Enhance bmcweb CLI app error messages. Replace the loglevel flag with a subcommand called "loglevel". Handle case where empty log levels were being propagated to bmcwebd. Invalid logging values are handled by the CLI. List of available states can be determined by using the command: bmcweb loglevel -h Example: bmcweb loglevel DEBUG bmcweb loglevel debug Change-Id: Iaac3f674109e5d86f6c0cd7c1b930ee1c9c594e2 Signed-off-by: Aushim Nagarkatti <anagarkatti@nvidia.com>
2024-09-04Fix includesEd Tanous4-6/+28
This commit is automatically generated by enabling clang-include-fixer. Tested: Code compiles. Change-Id: I475d7b9d43e95bbdeeaadf11905d3b2a60aa8ef3 Signed-off-by: Ed Tanous <etanous@nvidia.com>
2024-08-25Clang-format-18Ed Tanous1-8/+8
These files were checked in during the clang-18 merge. Update them. Change-Id: I857a87dac29469a4c24e83c6ee8b7c8461002f04 Signed-off-by: Ed Tanous <etanous@nvidia.com>