Benutzer:MovGP0/Zertifikate

  MovGP0    Über mich    Hilfen    Artikel    Weblinks    Literatur    Zitate    Notizen    Programmierung    MSCert    Physik   


SSL Zertifikat generieren

SelfSSL7[1]
selfssl /N "cn=localhost;cn=example.com" /V "EXPIRATIONTIMEINDAYS" /I /S "IISSITENAME" /X /F "KEYLOCATION\key.pfx" /W "PASSWORD" /T
Makecert
makecert -r -n "CN=localhost" -b 01/01/2000 -e 01/01/2099 -eku 1.3.6.1.5.5.7.3.3 -sv localhost.pvk localhost.cercert2spc localhost.cer localhost.spcpvk2pfx -pvk localhost.pvk -spc localhost.spc -pfx localhost.pfx

Für ObjectIDs (EKU-Codes) siehe KB287547

OpenSSL[2]
openssl genrsa -out localhost.key 2048openssl req -new -x509 -key localhost.key -out localhost.cert -days 3650 -subj /CN=localhost
PowerShell
# create root zertificate $rootCert = New-SelfSignedCertificate -CertStoreLocation cert:\localmachine\my -DnsName "Root CA Name";# export root certificate [System.Security.SecureString]$rootcertPassword = ConvertTo-SecureString -String "znft5yeL34pxCu3nATlt1gMazX0NM8FVvr9yZOhcS79yJm8kUVjhA17UuWkQOb0u" -Force -AsPlainText;[String]$rootCertPath = Join-Path -Path 'cert:\localMachine\my\' -ChildPath "$($rootcert.Thumbprint)";Export-PfxCertificate -Cert $rootCertPath -FilePath 'root-authority.pfx' -Password $rootcertPassword; # private keyExport-Certificate    -Cert $rootCertPath -FilePath 'root-authority.crt';                             # public key# use root certificate to sign gateway certificate$gatewayCert = New-SelfSignedCertificate -CertStoreLocation cert:\localmachine\my -DnsName "*.example.com","*.example.org" -Signer $rootCert;# export gateway certificate[System.Security.SecureString]$gatewayCertPassword = ConvertTo-SecureString -String "Xc8FlsHq8hmLnKXk4AaD8ug6HYH2dpSWLjwg9eNeDIK103d3akbd0OccgZZ6bL48" -Force -AsPlainText;[String]$gatewayCertPath = Join-Path -Path 'cert:\localMachine\my\' -ChildPath "$($gatewayCert.Thumbprint)";Export-PfxCertificate -Cert $gatewayCertPath -FilePath gateway-certificate.pfx -Password $gatewayCertPassword; # private keyExport-Certificate    -Cert $gatewayCertPath -FilePath gateway.crt;                                            # public key

See also:

Self-Signed Zertifikat für IIS [3]

Root-Zertifikat erstellen
makecert -n "CN=root.lan.ddg" -r -sv root.pvk root.cer

Zertifikat öffnen und nach Trusted Root Certification Authorities importieren

Server-Zertifikat erstellen und in IIS importieren
makecert -sk "Local Certificate" -iv root.pvk -n "CN=localhost" -ic root.cer -sr localmachine -ss my -sky exchange -pe

Anschließend in IIS das Binding der Website ändern, so dass das neue Zertifikat verwendet wird.

start inetmgr

Zertifikate für SharePoint

Zertifikaterstellung mit PowerShell

param([Parameter(Mandatory=$True)][string]$CertificateName)# paths$ExeMakeCert = "$env:ProgramFiles\Microsoft Office Servers\15.0\Tools\makecert.exe"$ExeCertManager = "$env:ProgramFiles\Microsoft Office Servers\15.0\Tools\certmgr.exe"$CertPath = "$env:UserProfile\MyCertificates"$CertName = $CertificateName + ".cer"# create the certificate$CertificateFullPath = Join-Path -Path $CertPath -ChildPath $CertName& "$ExeMakeCert -replace -pe -ne ""CN=www.dirry.eu"" -b 01/01/2025 -e 01/01/2025 -ss my -sr -localMachineName -sky exchange -sp ""Microsof RSA SChannel Cryptographic Provider"" -sy 12 $CertificateFullPath"# get certificate thumbprint $AppCertificate = Get-PfxCertificate -FilePath $CertificateFullPath# add certificate to local machine root& "$ExeCertManager /add $CertificateFullPath /s /r localMachine root"# export private key for certificateGet-ChildItem cert:\\localmachine\my | Where-Object { $_.Thumbprint -eq $AppCertificate.Thumbprint } | ForEach-Object {    $CertPfxName = (Get-Item -Path $CertificateFullPath).BaseName    $CertPfxName += ".pfx"    $CertExportPath = Join-Path -Path $CertPath -ChildPath $CertPfxName    $CertFileByteArray = $_.Export("PFX", $CertPassword)    [System.IO.File]::WriteAllBytes($CertExportPath, $CertFileByteArray)}

Import in web.config

<configuration>   <appSettings>      <add key="ClientId" value="223CFE50-182E-4C3C-A9B5-09BD4B55F404" />      <add key="ClientSigningCertificatePath" value="c:\...\MyCertificate.pfx" />      <add key="ClientSigningCertificatePassword" value="My T0p Secre7 Passw0rd" />   </appSettings></configuration>

Erstellung einer S2S STS

Erstellung einer Server-to-Server Security-Token-Service:

  1. Create a realm/tenancy
  2. Cretae realm-qualified app identifier
  3. Register app vertificate as trusted token issuer
  4. Register security principal used by app
# get references to site's auth realm$spweb = Get-SPWeb "http://sp.mydomain.com/"$realm = Get-SPAuthenticationRealm -ServiceContext $spweb.Site# if no App GUID was passed in, create oneif([string]::IsNullOrEmpty($AppGuid)) {   $AppGuid = [Guid]::NewGuid().ToString()}$fullAppIdentifier = $AppGuid + '@' + $realm# get certificate$certificate = Get-PfxCertificate $certificateFullPath#register app vertificate as trusted by SharePoint site$secureTokenIssuer = New-SPTrustedSecurityTokenIssuer -Name $AppDisplayName -Certificate $certificate -RegisteredIssuerName $fullAppIdentifier#register app principal $appPrincipal = Register-SPAppPrincipal -NameIdentifier $fullAppIdentifier -Site $spweb -DisplayName $AppDisplayName

SSL/TLS und X.509

Dateiformate

Dateiformate
ErweiterungErklärung
*.cerWindows Zertifikat

(enthält die gleichen Informationen wie *.pfx, jedoch ohne Private Key)

*.pvkPrivate Key
*.pfxX.509 Zertifikat mit Private Key im PKCS12 Format

(mit Passwort gesichert)

*.spcSoftware Publisher Certificate

Tools zum Verwalten von Zertifikaten

AnwendungBeschreibung
vertlm.mscMMC-Konsole für LocalMachine Zertifikate
certmgr.mscMMC-Konsole für CurrentUser Zertifikate
certreq.exeZertifikatimport
certutil.exe
Test-CertificateTestet ein Zertifikat auf Gültigkeit
New-SelfSignedCertificateErstellt ein neues Self-Signed-Zertifikat

New-SelfSignedCertificate -DnsName test.com, www.test.com, localhost -CertStoreLocation cert:\LocalMachine\My

cert:Zertifikatprovider

siehe auch: PKI Client Cmdlets in Windows PowerShell. In: Technet. Microsoft, abgerufen am 27. August 2013.

X.509 Attribute

X.509 Attribute[4]
Certificate AttributeDescription
Subject: CNthe certificate owner’s common name (www.yoursite.com oder yoursite.com)
Subject: Ethe certificate owner’s email address
Subject: Tthe certificate owner’s locality
Subject: STthe certificate owner’s state of residence
Subject: Othe organization to which the certificate owner belongs
Subject: OUthe name of the organizational unit to which the certificate owner belongs
Subject: Cthe certificate owner’s country of residence
Subject: STREETthe certificate owner’s street address
Subject: ALLthe certificate owner’s complete distinguished name
Issuer: CNthe certificate issuer’s common name (www.yoursite.com oder yoursite.com)
Issuer: Ethe certificate issuer’s email address
Issuer: Tthe certificate issuer’s locality
Issuer: STthe certificate issuer’s state of residence
Issuer: Othe organization to which the certificate issuer belongs
Issuer: OUthe name of the organizational unit to which the certificate issuer belongs
Issuer: Cthe certificate issuer’s country of residence
Issuer: STREETthe certificate issuer’s street address
Issuer: ALLthe certificate issuer’s complete distinguished name
Serialthe certificate’s serial number
SignatureAlgthe algorithm used by the Certificate Authority to sign the certificate
BeginDatethe date at which the certificate becomes valid
EndDatethe date at which the certificate becomes invalid
PublicKeythe certificate’s public key
FriendlyNamethe certificate’s friendly name
KeyUsage: ALLindicates the purposes for which the certificate’s public key can be used
KeyUsage: Digital Signaturethis certificate’s public key can create digital signatures
KeyUsage: NonRepudiationthis certificate’s public key can be used for non-repudiation
KeyUsage: KeyEnciphermentthis certificate’s public key can encipher keys
KeyUsage: DataEnciphermentthis certificate’s public key can encipher data
KeyUsage: KeyAgreementthis certificate’s public key can ensure that other public keys match their certificates. Used in certificate management.
KeyUsage: KeyCertSignthis certificate’s public key can sign key certificates
KeyUsage: CRLSignthis certificate’s public key can sign Certificate Revocation Lists
KeyUsage: EncipherOnlythis certificate’s public key can only encipher keys or data
KeyUsage: DecipherOnlythis certificate’s public key can only decipher keys or data
BasicConstraintsbehaves as though the fCA tag was specified
BasicConstraints: fCAdetermines whether the subject of this certificate can act as a Certificate Authority (1 if true, 0 if false)
BasicConstraints: pathLengththe number of CA certificates that can follow this certificate in a certification path.
Policiesreturns all of the Object Identification Numbers of the certificate's policies in a comma separated string
PolicyConstraints: requireExplicitPolicyindicates whether an explicit policy is required
PolicyConstraints: inhibitPolicyMappingindicates whether policy mapping is inhibited
Engine: Namethe name of the signature engine that created the certificate

Internetquelle

Einzelnachweise