Vanaf sgcWebSockets 4.4.7 wordt het gebruik van certificaten met SChannel als cryptobibliotheek ondersteund.
The SChannel implementation supports 2 types of certificate authentication:
1. Een PFX-certificaat gebruiken
2. De hash thumbprint instellen van een certificaat dat al in het Windows-systeem is geïnstalleerd.
PFX-certificaat
Een PFX-certificaat is een bestand dat het certificaat en de privésleutel bevat; soms heb je een certificaat in PEM-formaat en moet je het eerst converteren naar PFX voordat je het kunt gebruiken.
Gebruik het volgende OpenSSL-commando om een PEM-certificaat naar PFX te converteren
openssl pkcs12 -inkey certificate-pem.key -in certificate-pem.crt -export -out certificate.pfx
Zodra het certificaat in PFX-formaat is, hoef je het alleen maar te deployen en het pad in de eigenschap TLSOptions.Certificate in te stellen.
TLSOptions.IOHandler := iohSChannel; TLSOptions.CertFile := '<certificate path>'; TLSOptions.Password := '<certificate optional password>';
Hash thumbprint
Als het certificaat al in de Windows-certificate-store is geïnstalleerd, hoef je alleen de thumbprint van het certificaat te weten en deze in de eigenschap TLSOptions.SChannel_Options in te stellen.
De hash van een certificaat vinden in PowerShell is net zo eenvoudig als een dir-commando uitvoeren op de certificate-container.
dir cert:\localmachine\my
De hash is de hexadecimale Thumbprint-waarde.
Directory: Microsoft.PowerShell.Security\Certificate::localmachine\myThumbprint Subject---------- -------C12A8FC8AE668F866B48F23E753C93D357E9BE10 CN=*.mydomain.com
Zodra je de thumbprint-waarde hebt, moet je in de eigenschap TLSOptions.SChannel_Options de hash en de locatie van het certificaat instellen.
TLSOptions.IOHandler := iohSChannel; TLSOptions.SChannel_Options.CertHash := '<certificate thumbprint>'; TLSOptions.SChannel_Options.CertStoreName := '<certificate store name>'; TLSOptions.SChannel_Options.CertStorePath := '<certificate store path>'; TLSOptions.Password := '<certificate optional password>';
