This is a created article in which the information may have evolved or changed.
Today in the development of the HTTPS part of the Gsweb encountered a magical bug, recorded here for similar problems encountered by the classmate reference.
The cause of the matter is this:
I got a self-signed web certificate from my keychain at OSX 10.10, and I exported it for LISTENANDSERVETLS. Then Golang is not face to me. Always error: Crypto/tls:failed to parse key PEM data
Solutions
- Google a little bit to find Beego a issue also mentioned this problem. This link is mentioned in the inside;
- Read the last link, found it seems that the problem is X509keypair format is not correct;
- In this way, the public key format was changed to the "-----begin CERTIFICATE-----" format;
- Run the program or not;
- No way, only read the source code of the Golang. Found in the source code there is a program $goapth/libexec/src/crypto/tls/generate_cert.go;
- Using this program to generate a new certificate, the problem is solved!!!!!
Conclusion
Should it be a x509keypair format problem, either Golang only supports a specific format, or is there any configuration parameters? Ask the expert to answer???