The first step is generating security.toml file via weed scaffold -config=security:

  1. $ weed scaffold -config=security
  2. # Put this file to one of the location, with descending priority
  3. # ./security.toml
  4. # $HOME/.seaweedfs/security.toml
  5. # /etc/seaweedfs/security.toml
  6. # this file is read by master, volume server, and filer
  7. # the jwt signing key is read by master and volume server.
  8. # a jwt defaults to expire after 10 seconds.
  9. [jwt.signing]
  10. key = ""
  11. expires_after_seconds = 10 # seconds
  12. # jwt for read is only supported with master+volume setup. Filer does not support this mode.
  13. [jwt.signing.read]
  14. key = ""
  15. expires_after_seconds = 10 # seconds
  16. # volume server also uses grpc that should be secured.
  17. # all grpc tls authentications are mutual
  18. # the values for the following ca, cert, and key are paths to the PERM files.
  19. # the host name is not checked, so the PERM files can be shared.
  20. [grpc]
  21. ca = ""
  22. [grpc.volume]
  23. cert = ""
  24. key = ""
  25. [grpc.master]
  26. cert = ""
  27. key = ""
  28. [grpc.filer]
  29. cert = ""
  30. key = ""
  31. # use this for any place needs a grpc client
  32. # i.e., "weed backup|benchmark|filer.copy|filer.replicate|mount|s3|upload"
  33. [grpc.client]
  34. cert = ""
  35. key = ""

The following command is what I used to generate the private key and certificate files, using https://github.com/square/certstrap , or just go get github.com/square/certstrap

  1. certstrap init --common-name "SeaweedFS CA"
  2. certstrap request-cert --common-name volume01
  3. certstrap request-cert --common-name master01
  4. certstrap request-cert --common-name filer01
  5. certstrap request-cert --common-name client01
  6. certstrap sign --CA "SeaweedFS CA" volume01
  7. certstrap sign --CA "SeaweedFS CA" master01
  8. certstrap sign --CA "SeaweedFS CA" filer01
  9. certstrap sign --CA "SeaweedFS CA" client01

Here is my security.toml file content:

  1. # Put this file to one of the location, with descending priority
  2. # ./security.toml
  3. # $HOME/.seaweedfs/security.toml
  4. # /etc/seaweedfs/security.toml
  5. [jwt.signing]
  6. key = "blahblahblahblah"
  7. # all grpc tls authentications are mutual
  8. [grpc]
  9. ca = "/Users/chris/.seaweedfs/out/SeaweedFS_CA.crt"
  10. [grpc.volume]
  11. cert = "/Users/chris/.seaweedfs/out/volume01.crt"
  12. key = "/Users/chris/.seaweedfs/out/volume01.key"
  13. [grpc.master]
  14. cert = "/Users/chris/.seaweedfs/out/master01.crt"
  15. key = "/Users/chris/.seaweedfs/out/master01.key"
  16. [grpc.filer]
  17. cert = "/Users/chris/.seaweedfs/out/filer01.crt"
  18. key = "/Users/chris/.seaweedfs/out/filer01.key"
  19. [grpc.client]
  20. cert = "/Users/chris/.seaweedfs/out/client01.crt"
  21. key = "/Users/chris/.seaweedfs/out/client01.key"

For Java gRPC

Java gRPC uses Netty's SslContext. From https://netty.io/wiki/sslcontextbuilder-and-private-key.html

The SslContextBuilder and so Netty's SslContext implementations only support PKCS8 keys.

If you have a key with another format you need to convert it to PKCS8 first to be able to use it. This can be done easily by using openssl.

For example to convert a non-encrypted PKCS1 key to PKCS8 you would use:

openssl pkcs8 -topk8 -nocrypt -in pkcs1_key_file -out pkcs8_key.pem