'HTTPS POST request using only the server's public key?

Is it possible to send a HTTPS POST request to a server that you only have the public key to (and not the whole certificate - obviously not talking about the private key here)?

Here is my setup. Both Server and client are developed and controlled by me.

  • HTTPS Server
    • has untrusted root certificate for https (from ZeroSSL, 90 days expiration)
  • Java Client (on github - open source)
    • has to send a file over an https connection
    • the app is downloaded by random people with varying technical knowledge (manual file imports for java key storage - as I've seen them in many stackoverfow posts - are not an option)
    • the client app runns more than 90 days (hardcoding certificates is not an option, but the server's public key should stay the same after a renewal, which would make hardcoding this one in possible)
    • I want this to be as secure as possible (trusting all certificates is also not an option)

Now i've seen one person talk about "pinning the server's public key" in a comment. Does anyone know more about how to do that? It sounds exactly like the thing I'm looking for.


UPDATE 1: This site https://whatsmychaincert.com/ fixed at least a problem I had with my certificate not being installed properly, where firefox was fine with it, but ZeroSSL told me it wasn't properly installed. What that site did was to create a chained.crt file that basically consists out of the content from certificate.crt and the ca_bundle.crt combined (copypasted one and then the other file content with a line break in between). This file i then put instead of the certificate file in the node-red settings.js.

/** Option 1: static object */
https: {
    key: require("fs").readFileSync('private.key'),
    cert: require("fs").readFileSync('chained.crt')
},

It made things better but let's see if it also fixed my main problem...



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source