I am working on a java program and I am now working on its network security. I want to use a secure connection since it transfers a lot of sensitive information. On all security guides it is mentioned to always go with a standard way and dont use your own encryption/way.
Are there any security issues if I use my own public/private key pair without it being a trusted certificate? I understand that an attacker can send its own key during the exchange but what if the key is standard and I hardcode it into the code?