Note: This answer was tested using macOS High Sierra 10.13.6 and macOS Monterey 12.1. The images below are from Monterey.
Picking up from where the tutorial left off, I have the public and private keys in the Keychain Access application, as shown below.

From the Keychain Access application, you can export the public and private keys to files. Here, I saved the public key as nctest.com
in my Documents
folder, which created the text file ~/Documents/nctest.com.pem
. I also saved the private key as nctest.com
in my in my Documents
folder, which created the text file ~/Documents/nctest.com.p12
. When prompted, I chose to not to enter a password. In other words, when the popup below appeared, I did not enter any text in the "Password:" or "Verify:" text boxes and just selected the OK
button. For the purposes of additional security, you may wish to enter a stronger password.

The public key can be displayed by entering the following command in a Terminal application window.
cat ~/Documents/nctest.com.pem
Sample output is given below.
-----BEGIN RSA PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvF52ctPK2AJctLlBoDn9
tisRPPUqFUuBsyqUezm8QbmUNhnAfNN+skteXU9Mud042f+5NLDnsCg9PuiMAXqJ
YEd7PU/iYU7fYCnjNAJriyjSQ8ClV9KYN/4KSeSvc9NBizAbYFeJqcQ4HDPIg0bA
Chxcdy02T1W47TtizIh6oGxM7kFqBCJ1wrZKz2nAEggAZFp2SH3ZvlGkfsVOvfKd
wrOezYI3D1cx97BVGEj+U9Ciaz5e63cScqgTIoEAsdcCNT6f15odMmzvqN58LfSS
gIokL+2IjcEeZqYgj1TE9LA/7D0hLrnU5sKr6Cs1SJQH8X3+WpS0GSOlBOyx16+H
8wIDAQAB
-----END RSA PUBLIC KEY-----
The private key can be displayed by entering the following command in a Terminal application window.
Note: If you entered some text for a password, then this password needs to be included immediately after the colon (:
) character. Or, you can be prompted for the password by omitting the -passin pass:
option and argument.
openssl pkcs12 -nodes -passin pass: -in ~/Documents/nctest.com.p12
Sample output is given below.
MAC verified OK
Bag Attributes
friendlyName: nctest.com
localKeyID: F4 47 72 98 49 70 3B E6 80 C6 2A A1 27 BB 8B F4 0B BC 3F E9
Key Attributes: <No Attributes>
-----BEGIN PRIVATE KEY-----
MIIEvQIBAD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ox4PVLKIS
V1ZV9WWUCwKBgCj+/z1jPWSy3dBZaUy3ImiYH1Vbd8zd0EHp9PTXxPBePW4MO3Pn
uSSUqH/7wRfza+xYEwkk9CEVwv8C0NTwrVmtIoWxA/fA/TBmDPCzqdGpX27ndLmf
8UODX8J30oIngktB5WtmsSRA5pUIGBMQXKa1qMmdb//v20yNH/8Fy9fpAoGAd1RB
7CEGUkgvNlCzOO11F6ztySuhnNzTXDiQfSVq/+7iTzVaAiQId0jXFldc69vA1CSp
VOqr9y0qEqi3mZpk9uyPE/n0YxElmwAOQfKjyN9VH7Veb34ExjP4L69Co8OIjAuR
9hFikaJjMJz88nyooDwZDY4gqpg5frkK7LA2SusCgYEA72DWlN+OmP/IWJyG0xb4
sj/wWEgejI1QqLPVdyBFQQApmwhRUa7V6YmkmzClh7Hklk3o+G1fx+fi70CWB9Nw
XJZsDFJfLDdD5SIrQumiPiowrUH5pdHJJj2C+cPAKi+cxSCd76OmxtEX3wWT4rNV
dGPsLLntAJEOwhzyGzNb4c4=
-----END PRIVATE KEY-----
You can verify the public key was generated from the private key by entering the command below in a Terminal application window.
openssl pkcs12 -nodes -passin pass: -in ~/Documents/nctest.com.p12 | openssl rsa -pubout
Sample output is given below.
MAC verified OK
writing RSA key
-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvF52ctPK2AJctLlBoDn9
tisRPPUqFUuBsyqUezm8QbmUNhnAfNN+skteXU9Mud042f+5NLDnsCg9PuiMAXqJ
YEd7PU/iYU7fYCnjNAJriyjSQ8ClV9KYN/4KSeSvc9NBizAbYFeJqcQ4HDPIg0bA
Chxcdy02T1W47TtizIh6oGxM7kFqBCJ1wrZKz2nAEggAZFp2SH3ZvlGkfsVOvfKd
wrOezYI3D1cx97BVGEj+U9Ciaz5e63cScqgTIoEAsdcCNT6f15odMmzvqN58LfSS
gIokL+2IjcEeZqYgj1TE9LA/7D0hLrnU5sKr6Cs1SJQH8X3+WpS0GSOlBOyx16+H
8wIDAQAB
-----END PUBLIC KEY-----
References: