Skip to content

[Bug]: citrixadc_systemfile double-encoding when passing base64 filecontent #1300

@yakyouk

Description

@yakyouk

Terraform Core Version

1.11.4

citrixadc Provider Version

1.43.1

Operating system

Windows 11

Affected Resource(s)

citrixadc_systemfile

Equivalent NetScaler CLI Command

N/A

Expected Behavior

When uploading a file with fileencoding="BASE64" (default), passing b64-encoded content to filecontent, the resulting file should contain the decoded bytes.

Actual Behavior

The resulting file on the server contains the passed base64 string instead of the decoded bytes:

  • the provider encodes filecontent again before uploading the file, despite the fact that it should already be base64;
  • conversely, when fetching content from the server, the content is decoded, resulting in binary gibberish in the state.
    The content does not respect sensitive(), see related issue.

Relevant Error/Panic Output Snippet

Terraform Configuration Files

resource "citrixadc_systemfile" "pfx" {
  for_each = local.certs
  filelocation = "/nsconfig/ssl"
  filename = each.value.filename
  filecontent = each.value.filecontent_b64
  fileencoding = "BASE64"
}

Steps to Reproduce

upload a binary file using citrixadc_systemfile, passing the b64-encoded binary content to filecontent

Debug Output

No response

Panic Output

No response

Important Factoids

  • Netscaler documentation states that passed data must be Base64, this is consistent with how the Nitro API is called.
  • Terraform does not do well with binary strings so having to pass plain data to filecontent is tricky. For example it is not possible to read a binary file directly into a string.

References

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions