<p>I use OpenSSL &amp; generated self signed certificate &amp; key files.</p>
<p>Now I try to transform them to base64 encoded value in order to put into kubernetes &quot;Secret&quot; manifest. I tried <a href="https://stackoverflow.com/questions/48341240/transform-ssl-crt-to-kubernetes-inline-format">the answer from this post</a>.</p>
<p>But the accepted answer doesn't work for me, this is what I get:</p>
<pre><code>cat myapp.com.crt | base64 -w0
base64: invalid argument -w0
Usage:  base64 [-hDd] [-b num] [-i in_file] [-o out_file]
  -h, --help     display this message
  -Dd, --decode   decodes input
  -b, --break    break encoded string into num character lines
  -i, --input    input file (default: &quot;-&quot; for stdin)
  -o, --output   output file (default: &quot;-&quot; for stdout)
</code></pre>
<p>Why is that? How to get the base64 encoded value for my certificate so that I can use the value in k8s secret manifest?</p>

user842225
<p>What kind of distro are you using? It seems that your <code>base64</code> binary is not the same program as used in your referenced answer.</p>
<p>On Ubuntu (20.04) it should work:</p>
<pre><code>base64 --help
Usage: base64 [OPTION]... [FILE]
Base64 encode or decode FILE, or standard input, to standard output.

With no FILE, or when FILE is -, read standard input.

Mandatory arguments to long options are mandatory for short options too.
  -d, --decode          decode data
  -i, --ignore-garbage  when decoding, ignore non-alphabet characters
  -w, --wrap=COLS       wrap encoded lines after COLS character (default 76).
                          Use 0 to disable line wrapping

      --help     display this help and exit
      --version  output version information and exit
</code></pre>
<p>Or you can just use <code>cat server.csr | base64 | tr -d '\n'</code> as mentioned in <a href="https://stackoverflow.com/a/48341521/20424756">this answer</a>.</p>
