The strongswan documentation states:
A preshared secret is most conveniently represented as a sequence of characters, which is delimited by double-quote characters ("). The sequence cannot contain newline or double-quote characters.
Alternatively, preshared secrets can be represented as hexadecimal or Base64 encoded binary values. A character sequence beginning with 0x is interpreted as sequence hexadecimal digits. Similarly, a character sequence beginning with 0s is interpreted as Base64 encoded binary data.
Using hex- or base64-encoding in the /etc/ipsec.secrets file would allow double quotes- and newline-characters to be used in VPN PSKs (double quotes being a requirement we just encountered connecting to an ISP's Cisco VPN).
The change is as simple as encoding the PSK, prepending "0s" (base64) or "0x" (hex) and putting the result unquoted (!) into the file.
The problem is that the value is checked for illegal characters in a completely different place.
Changing that unfortunately exceeds my coding abilities.
This will probably get a low priority but I at least wanted to document my findings.