smtp4dev
smtp4dev copied to clipboard
type of certificate
Hello,
What type of certificate must I use for tls? I have .crt and .key certificates. Do I need to convert them to some format?
I created kube secret:
kubectl create secret tls mail-tls --key=cert.key --cert=cert.crt
and deployed app with next deployment:
apiVersion: apps/v1
kind: Deployment
metadata:
name: smtp4dev
spec:
replicas: 1
selector:
matchLabels:
app: smtp4dev
template:
metadata:
labels:
app: smtp4dev
spec:
containers:
- name: smtp4dev
image: rnwood/smtp4dev
env:
- name: ServerOptions__TlsMode
value: "StartTls"
- name: ServerOptions__TlsCertificate
valueFrom:
secretKeyRef:
name: mail-tls
key: tls.crt
- name: ServerOptions__TlsCertificatePrivateKey
valueFrom:
secretKeyRef:
name: mail-tls
key: tls.key
ports:
- containerPort: 25
name: smtp
- containerPort: 80
name: http
volumeMounts:
- name: tls-volume
mountPath: /tls
volumes:
- name: tls-volume
secret:
secretName: mail-tls
after that I got an error:
The SMTP server failed to start: System.IO.DirectoryNotFoundException: Could not find a part of the path '/smtp4dev/-----BEGIN PRIVATE KEY-----
.
.
.
-----END PRIVATE KEY-----'.
at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirectory, Func`2 errorRewriter)
at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode)
at System.IO.FileStream.OpenHandle(FileMode mode, FileShare share, FileOptions options)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
at System.IO.StreamReader.ValidateArgsAndOpenPath(String path, Encoding encoding, Int32 bufferSize)
at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks)
at System.IO.File.InternalReadAllText(String path, Encoding encoding)
at System.IO.File.ReadAllText(String path)
at Rnwood.Smtp4dev.Server.CertificateHelper.LoadCertificateWithKey(String certificatePath, String certificateKeyPath) in /app/Rnwood.Smtp4dev/Server/CertificateHelper.cs:line 20
at Rnwood.Smtp4dev.Server.Smtp4devServer.GetTlsCertificate() in /app/Rnwood.Smtp4dev/Server/Smtp4devServer.cs:line 102
at Rnwood.Smtp4dev.Server.Smtp4devServer.CreateSmtpServer() in /app/Rnwood.Smtp4dev/Server/Smtp4devServer.cs:line 61
at Rnwood.Smtp4dev.Server.Smtp4devServer.TryStart() in /app/Rnwood.Smtp4dev/Server/Smtp4devServer.cs:line 396
System.IO.DirectoryNotFoundException: Could not find a part of the path '/smtp4dev/-----BEGIN PRIVATE KEY-----
.
.
.
-----END PRIVATE KEY-----'.
at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirectory, Func`2 errorRewriter)
at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode)
at System.IO.FileStream.OpenHandle(FileMode mode, FileShare share, FileOptions options)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
at System.IO.StreamReader.ValidateArgsAndOpenPath(String path, Encoding encoding, Int32 bufferSize)
at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks)
at System.IO.File.InternalReadAllText(String path, Encoding encoding)
at System.IO.File.ReadAllText(String path)
at Rnwood.Smtp4dev.Server.CertificateHelper.LoadCertificateWithKey(String certificatePath, String certificateKeyPath) in /app/Rnwood.Smtp4dev/Server/CertificateHelper.cs:line 20
at Rnwood.Smtp4dev.Server.Smtp4devServer.GetTlsCertificate() in /app/Rnwood.Smtp4dev/Server/Smtp4devServer.cs:line 102
at Rnwood.Smtp4dev.Server.Smtp4devServer.CreateSmtpServer() in /app/Rnwood.Smtp4dev/Server/Smtp4devServer.cs:line 61
at Rnwood.Smtp4dev.Server.Smtp4devServer.TryStart() in /app/Rnwood.Smtp4dev/Server/Smtp4devServer.cs:line 396
how to fix it? help, please
Settings files comments, command line help and wiki improved.
https://github.com/rnwood/smtp4dev/wiki/TLS-SSL-for-SMTP