client/rpcserver: fix cert handling in handlePostBond - #3624
Open
Share-coin wants to merge 1 commit into
Open
Conversation
form.Cert arrives from bwctl as a JSON string when a cert filepath is given on the command line - optionalTextFiles pre-reads the file into its raw content before sending, same as handleGetDEXConfig receives. handleGetDEXConfig explicitly converts that string to []byte before passing it to core, so parseCert takes its []byte branch and uses the content directly. handlePostBond does not do this conversion, so form.Cert (typed any) unmarshals as a plain Go string, and core.parseCert treats that string as a filepath and tries to re-read the PEM content as if it were a filename - always fails with a misleading "failed to read certificate file from -----BEGIN CERTIFICATE-----..." error. Adds the same string-to-[]byte conversion handleGetDEXConfig already does, so postbond with a cert filepath argument actually works.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
handlePostBonddoesn't convertform.Certfrom a JSON string to[]bytebefore use, unlikehandleGetDEXConfigtwo functions above it (which does exactly this conversion, for exactly this reason).bwctl'soptionalTextFilespre-reads a cert filepath argument into the certificate's raw content before sending it over RPC.handleGetDEXConfig's params struct typesCertasstringand explicitly converts it to[]bytebefore passing to core, soparseCerttakes its[]bytebranch and uses the content directly.core.PostBondForm.Certis typedany, so it unmarshals as a plain Gostringinstead, andcore.parseCert'sstringbranch tries to re-read that PEM content as if it were a filename - always fails with a misleadingfailed to read certificate file from -----BEGIN CERTIFICATE-----...error.Adds the same string-to-
[]byteconversionhandleGetDEXConfigalready does, sobwctl postbond <host> <bond> ... <certpath>actually works for registering a new DEX.Test plan
go build ./client/rpcserver/...cleangofmt -lcleanbwctl postbondwith a cert filepath failed with the misleading file-read error before this change, succeeded (real bond posted, confirmed on-chain) after