CertificateConfig.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using System.Configuration;
  5. using SuperSocket.SocketBase.Config;
  6. using System.Security.Cryptography.X509Certificates;
  7. namespace SuperSocket.SocketEngine.Configuration
  8. {
  9. /// <summary>
  10. /// Certificate configuration
  11. /// </summary>
  12. public class CertificateConfig : ConfigurationElement, ICertificateConfig
  13. {
  14. #region ICertificateConfig Members
  15. /// <summary>
  16. /// Gets the certificate file path.
  17. /// </summary>
  18. [ConfigurationProperty("filePath", IsRequired = false)]
  19. public string FilePath
  20. {
  21. get
  22. {
  23. return this["filePath"] as string;
  24. }
  25. }
  26. /// <summary>
  27. /// Gets the password.
  28. /// </summary>
  29. [ConfigurationProperty("password", IsRequired = false)]
  30. public string Password
  31. {
  32. get
  33. {
  34. return this["password"] as string;
  35. }
  36. }
  37. /// <summary>
  38. /// Gets the the store where certificate locates.
  39. /// </summary>
  40. /// <value>
  41. /// The name of the store.
  42. /// </value>
  43. [ConfigurationProperty("storeName", IsRequired = false)]
  44. public string StoreName
  45. {
  46. get
  47. {
  48. return this["storeName"] as string;
  49. }
  50. }
  51. /// <summary>
  52. /// Gets the store location of the certificate.
  53. /// </summary>
  54. /// <value>
  55. /// The store location.
  56. /// </value>
  57. [ConfigurationProperty("storeLocation", IsRequired = false, DefaultValue = "CurrentUser")]
  58. public StoreLocation StoreLocation
  59. {
  60. get
  61. {
  62. return (StoreLocation)this["storeLocation"];
  63. }
  64. }
  65. /// <summary>
  66. /// Gets the thumbprint.
  67. /// </summary>
  68. [ConfigurationProperty("thumbprint", IsRequired = false)]
  69. public string Thumbprint
  70. {
  71. get
  72. {
  73. return this["thumbprint"] as string;
  74. }
  75. }
  76. /// <summary>
  77. /// Gets a value indicating whether [client certificate required].
  78. /// </summary>
  79. /// <value>
  80. /// <c>true</c> if [client certificate required]; otherwise, <c>false</c>.
  81. /// </value>
  82. [ConfigurationProperty("clientCertificateRequired", IsRequired = false, DefaultValue = false)]
  83. public bool ClientCertificateRequired
  84. {
  85. get
  86. {
  87. return (bool)this["clientCertificateRequired"];
  88. }
  89. }
  90. /// <summary>
  91. /// Gets a value that will be used to instantiate the X509Certificate2 object in the CertificateManager
  92. /// </summary>
  93. [ConfigurationProperty("keyStorageFlags", IsRequired = false, DefaultValue = X509KeyStorageFlags.DefaultKeySet)]
  94. public X509KeyStorageFlags KeyStorageFlags
  95. {
  96. get
  97. {
  98. return (X509KeyStorageFlags)this["keyStorageFlags"];
  99. }
  100. }
  101. #endregion ICertificateConfig Members
  102. }
  103. }