You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1602 lines
58 KiB

8 years ago
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1">
  6. <meta name="theme-color" content="#375EAB">
  7. <title>x509 - The Go Programming Language</title>
  8. <link type="text/css" rel="stylesheet" href="../../../lib/godoc/style.css">
  9. <link rel="stylesheet" href="../../../lib/godoc/jquery.treeview.css">
  10. <script type="text/javascript">window.initFuncs = [];</script>
  11. </head>
  12. <body>
  13. <div id='lowframe' style="position: fixed; bottom: 0; left: 0; height: 0; width: 100%; border-top: thin solid grey; background-color: white; overflow: auto;">
  14. ...
  15. </div><!-- #lowframe -->
  16. <div id="topbar" class="wide"><div class="container">
  17. <div class="top-heading" id="heading-wide"><a href="http://localhost:6060/">The Go Programming Language</a></div>
  18. <div class="top-heading" id="heading-narrow"><a href="http://localhost:6060/">Go</a></div>
  19. <a href="index.html#" id="menu-button"><span id="menu-button-arrow">&#9661;</span></a>
  20. <form method="GET" action="http://localhost:6060/search">
  21. <div id="menu">
  22. <a href="http://localhost:6060/doc/">Documents</a>
  23. <a href="http://localhost:6060/pkg/">Packages</a>
  24. <a href="http://localhost:6060/project/">The Project</a>
  25. <a href="http://localhost:6060/help/">Help</a>
  26. <a href="http://localhost:6060/blog/">Blog</a>
  27. <input type="text" id="search" name="q" class="inactive" value="Search" placeholder="Search">
  28. </div>
  29. </form>
  30. </div></div>
  31. <div id="page" class="wide">
  32. <div class="container">
  33. <h1>Package x509</h1>
  34. <div id="nav"></div>
  35. <!--
  36. Copyright 2009 The Go Authors. All rights reserved.
  37. Use of this source code is governed by a BSD-style
  38. license that can be found in the LICENSE file.
  39. -->
  40. <!--
  41. Note: Static (i.e., not template-generated) href and id
  42. attributes start with "pkg-" to make it impossible for
  43. them to conflict with generated attributes (some of which
  44. correspond to Go identifiers).
  45. -->
  46. <script type='text/javascript'>
  47. document.ANALYSIS_DATA = null;
  48. document.CALLGRAPH = null;
  49. </script>
  50. <div id="short-nav">
  51. <dl>
  52. <dd><code>import "crypto/x509"</code></dd>
  53. </dl>
  54. <dl>
  55. <dd><a href="index.html#pkg-overview" class="overviewLink">Overview</a></dd>
  56. <dd><a href="index.html#pkg-index" class="indexLink">Index</a></dd>
  57. <dd><a href="index.html#pkg-examples" class="examplesLink">Examples</a></dd>
  58. <dd><a href="index.html#pkg-subdirectories">Subdirectories</a></dd>
  59. </dl>
  60. </div>
  61. <!-- The package's Name is printed as title by the top-level template -->
  62. <div id="pkg-overview" class="toggleVisible">
  63. <div class="collapsed">
  64. <h2 class="toggleButton" title="Click to show Overview section">Overview ▹</h2>
  65. </div>
  66. <div class="expanded">
  67. <h2 class="toggleButton" title="Click to hide Overview section">Overview ▾</h2>
  68. <p>
  69. Package x509 parses X.509-encoded keys and certificates.
  70. </p>
  71. </div>
  72. </div>
  73. <div id="pkg-index" class="toggleVisible">
  74. <div class="collapsed">
  75. <h2 class="toggleButton" title="Click to show Index section">Index ▹</h2>
  76. </div>
  77. <div class="expanded">
  78. <h2 class="toggleButton" title="Click to hide Index section">Index ▾</h2>
  79. <!-- Table of contents for API; must be named manual-nav to turn off auto nav. -->
  80. <div id="manual-nav">
  81. <dl>
  82. <dd><a href="index.html#pkg-variables">Variables</a></dd>
  83. <dd><a href="index.html#CreateCertificate">func CreateCertificate(rand io.Reader, template, parent *Certificate, pub, priv interface{}) (cert []byte, err error)</a></dd>
  84. <dd><a href="index.html#CreateCertificateRequest">func CreateCertificateRequest(rand io.Reader, template *CertificateRequest, priv interface{}) (csr []byte, err error)</a></dd>
  85. <dd><a href="index.html#DecryptPEMBlock">func DecryptPEMBlock(b *pem.Block, password []byte) ([]byte, error)</a></dd>
  86. <dd><a href="index.html#EncryptPEMBlock">func EncryptPEMBlock(rand io.Reader, blockType string, data, password []byte, alg PEMCipher) (*pem.Block, error)</a></dd>
  87. <dd><a href="index.html#IsEncryptedPEMBlock">func IsEncryptedPEMBlock(b *pem.Block) bool</a></dd>
  88. <dd><a href="index.html#MarshalECPrivateKey">func MarshalECPrivateKey(key *ecdsa.PrivateKey) ([]byte, error)</a></dd>
  89. <dd><a href="index.html#MarshalPKCS1PrivateKey">func MarshalPKCS1PrivateKey(key *rsa.PrivateKey) []byte</a></dd>
  90. <dd><a href="index.html#MarshalPKIXPublicKey">func MarshalPKIXPublicKey(pub interface{}) ([]byte, error)</a></dd>
  91. <dd><a href="index.html#ParseCRL">func ParseCRL(crlBytes []byte) (certList *pkix.CertificateList, err error)</a></dd>
  92. <dd><a href="index.html#ParseCertificates">func ParseCertificates(asn1Data []byte) ([]*Certificate, error)</a></dd>
  93. <dd><a href="index.html#ParseDERCRL">func ParseDERCRL(derBytes []byte) (certList *pkix.CertificateList, err error)</a></dd>
  94. <dd><a href="index.html#ParseECPrivateKey">func ParseECPrivateKey(der []byte) (key *ecdsa.PrivateKey, err error)</a></dd>
  95. <dd><a href="index.html#ParsePKCS1PrivateKey">func ParsePKCS1PrivateKey(der []byte) (key *rsa.PrivateKey, err error)</a></dd>
  96. <dd><a href="index.html#ParsePKCS8PrivateKey">func ParsePKCS8PrivateKey(der []byte) (key interface{}, err error)</a></dd>
  97. <dd><a href="index.html#ParsePKIXPublicKey">func ParsePKIXPublicKey(derBytes []byte) (pub interface{}, err error)</a></dd>
  98. <dd><a href="index.html#CertPool">type CertPool</a></dd>
  99. <dd>&nbsp; &nbsp; <a href="index.html#NewCertPool">func NewCertPool() *CertPool</a></dd>
  100. <dd>&nbsp; &nbsp; <a href="index.html#CertPool.AddCert">func (s *CertPool) AddCert(cert *Certificate)</a></dd>
  101. <dd>&nbsp; &nbsp; <a href="index.html#CertPool.AppendCertsFromPEM">func (s *CertPool) AppendCertsFromPEM(pemCerts []byte) (ok bool)</a></dd>
  102. <dd>&nbsp; &nbsp; <a href="index.html#CertPool.Subjects">func (s *CertPool) Subjects() (res [][]byte)</a></dd>
  103. <dd><a href="index.html#Certificate">type Certificate</a></dd>
  104. <dd>&nbsp; &nbsp; <a href="index.html#ParseCertificate">func ParseCertificate(asn1Data []byte) (*Certificate, error)</a></dd>
  105. <dd>&nbsp; &nbsp; <a href="index.html#Certificate.CheckCRLSignature">func (c *Certificate) CheckCRLSignature(crl *pkix.CertificateList) (err error)</a></dd>
  106. <dd>&nbsp; &nbsp; <a href="index.html#Certificate.CheckSignature">func (c *Certificate) CheckSignature(algo SignatureAlgorithm, signed, signature []byte) (err error)</a></dd>
  107. <dd>&nbsp; &nbsp; <a href="index.html#Certificate.CheckSignatureFrom">func (c *Certificate) CheckSignatureFrom(parent *Certificate) (err error)</a></dd>
  108. <dd>&nbsp; &nbsp; <a href="index.html#Certificate.CreateCRL">func (c *Certificate) CreateCRL(rand io.Reader, priv interface{}, revokedCerts []pkix.RevokedCertificate, now, expiry time.Time) (crlBytes []byte, err error)</a></dd>
  109. <dd>&nbsp; &nbsp; <a href="index.html#Certificate.Equal">func (c *Certificate) Equal(other *Certificate) bool</a></dd>
  110. <dd>&nbsp; &nbsp; <a href="index.html#Certificate.Verify">func (c *Certificate) Verify(opts VerifyOptions) (chains [][]*Certificate, err error)</a></dd>
  111. <dd>&nbsp; &nbsp; <a href="index.html#Certificate.VerifyHostname">func (c *Certificate) VerifyHostname(h string) error</a></dd>
  112. <dd><a href="index.html#CertificateInvalidError">type CertificateInvalidError</a></dd>
  113. <dd>&nbsp; &nbsp; <a href="index.html#CertificateInvalidError.Error">func (e CertificateInvalidError) Error() string</a></dd>
  114. <dd><a href="index.html#CertificateRequest">type CertificateRequest</a></dd>
  115. <dd>&nbsp; &nbsp; <a href="index.html#ParseCertificateRequest">func ParseCertificateRequest(asn1Data []byte) (*CertificateRequest, error)</a></dd>
  116. <dd>&nbsp; &nbsp; <a href="index.html#CertificateRequest.CheckSignature">func (c *CertificateRequest) CheckSignature() (err error)</a></dd>
  117. <dd><a href="index.html#ConstraintViolationError">type ConstraintViolationError</a></dd>
  118. <dd>&nbsp; &nbsp; <a href="index.html#ConstraintViolationError.Error">func (ConstraintViolationError) Error() string</a></dd>
  119. <dd><a href="index.html#ExtKeyUsage">type ExtKeyUsage</a></dd>
  120. <dd><a href="index.html#HostnameError">type HostnameError</a></dd>
  121. <dd>&nbsp; &nbsp; <a href="index.html#HostnameError.Error">func (h HostnameError) Error() string</a></dd>
  122. <dd><a href="index.html#InsecureAlgorithmError">type InsecureAlgorithmError</a></dd>
  123. <dd>&nbsp; &nbsp; <a href="index.html#InsecureAlgorithmError.Error">func (e InsecureAlgorithmError) Error() string</a></dd>
  124. <dd><a href="index.html#InvalidReason">type InvalidReason</a></dd>
  125. <dd><a href="index.html#KeyUsage">type KeyUsage</a></dd>
  126. <dd><a href="index.html#PEMCipher">type PEMCipher</a></dd>
  127. <dd><a href="index.html#PublicKeyAlgorithm">type PublicKeyAlgorithm</a></dd>
  128. <dd><a href="index.html#SignatureAlgorithm">type SignatureAlgorithm</a></dd>
  129. <dd>&nbsp; &nbsp; <a href="index.html#SignatureAlgorithm.String">func (algo SignatureAlgorithm) String() string</a></dd>
  130. <dd><a href="index.html#SystemRootsError">type SystemRootsError</a></dd>
  131. <dd>&nbsp; &nbsp; <a href="index.html#SystemRootsError.Error">func (SystemRootsError) Error() string</a></dd>
  132. <dd><a href="index.html#UnhandledCriticalExtension">type UnhandledCriticalExtension</a></dd>
  133. <dd>&nbsp; &nbsp; <a href="index.html#UnhandledCriticalExtension.Error">func (h UnhandledCriticalExtension) Error() string</a></dd>
  134. <dd><a href="index.html#UnknownAuthorityError">type UnknownAuthorityError</a></dd>
  135. <dd>&nbsp; &nbsp; <a href="index.html#UnknownAuthorityError.Error">func (e UnknownAuthorityError) Error() string</a></dd>
  136. <dd><a href="index.html#VerifyOptions">type VerifyOptions</a></dd>
  137. </dl>
  138. </div><!-- #manual-nav -->
  139. <div id="pkg-examples">
  140. <h4>Examples</h4>
  141. <dl>
  142. <dd><a class="exampleLink" href="index.html#example_Certificate_Verify">Certificate.Verify</a></dd>
  143. </dl>
  144. </div>
  145. <h4>Package files</h4>
  146. <p>
  147. <span style="font-size:90%">
  148. <a href="http://localhost:6060/src/crypto/x509/cert_pool.go">cert_pool.go</a>
  149. <a href="http://localhost:6060/src/crypto/x509/pem_decrypt.go">pem_decrypt.go</a>
  150. <a href="http://localhost:6060/src/crypto/x509/pkcs1.go">pkcs1.go</a>
  151. <a href="http://localhost:6060/src/crypto/x509/pkcs8.go">pkcs8.go</a>
  152. <a href="http://localhost:6060/src/crypto/x509/root.go">root.go</a>
  153. <a href="http://localhost:6060/src/crypto/x509/root_linux.go">root_linux.go</a>
  154. <a href="http://localhost:6060/src/crypto/x509/root_unix.go">root_unix.go</a>
  155. <a href="http://localhost:6060/src/crypto/x509/sec1.go">sec1.go</a>
  156. <a href="http://localhost:6060/src/crypto/x509/verify.go">verify.go</a>
  157. <a href="http://localhost:6060/src/crypto/x509/x509.go">x509.go</a>
  158. </span>
  159. </p>
  160. </div><!-- .expanded -->
  161. </div><!-- #pkg-index -->
  162. <div id="pkg-callgraph" class="toggle" style="display: none">
  163. <div class="collapsed">
  164. <h2 class="toggleButton" title="Click to show Internal Call Graph section">Internal call graph ▹</h2>
  165. </div> <!-- .expanded -->
  166. <div class="expanded">
  167. <h2 class="toggleButton" title="Click to hide Internal Call Graph section">Internal call graph ▾</h2>
  168. <p>
  169. In the call graph viewer below, each node
  170. is a function belonging to this package
  171. and its children are the functions it
  172. calls&mdash;perhaps dynamically.
  173. </p>
  174. <p>
  175. The root nodes are the entry points of the
  176. package: functions that may be called from
  177. outside the package.
  178. There may be non-exported or anonymous
  179. functions among them if they are called
  180. dynamically from another package.
  181. </p>
  182. <p>
  183. Click a node to visit that function's source code.
  184. From there you can visit its callers by
  185. clicking its declaring <code>func</code>
  186. token.
  187. </p>
  188. <p>
  189. Functions may be omitted if they were
  190. determined to be unreachable in the
  191. particular programs or tests that were
  192. analyzed.
  193. </p>
  194. <!-- Zero means show all package entry points. -->
  195. <ul style="margin-left: 0.5in" id="callgraph-0" class="treeview"></ul>
  196. </div>
  197. </div> <!-- #pkg-callgraph -->
  198. <h2 id="pkg-variables">Variables</h2>
  199. <pre>var <span id="ErrUnsupportedAlgorithm">ErrUnsupportedAlgorithm</span> = <a href="../../errors/index.html">errors</a>.<a href="../../errors/index.html#New">New</a>(&#34;x509: cannot verify signature: algorithm unimplemented&#34;)</pre>
  200. <p>
  201. ErrUnsupportedAlgorithm results from attempting to perform an operation that
  202. involves algorithms that are not currently implemented.
  203. </p>
  204. <pre>var <span id="IncorrectPasswordError">IncorrectPasswordError</span> = <a href="../../errors/index.html">errors</a>.<a href="../../errors/index.html#New">New</a>(&#34;x509: decryption password incorrect&#34;)</pre>
  205. <p>
  206. IncorrectPasswordError is returned when an incorrect password is detected.
  207. </p>
  208. <h2 id="CreateCertificate">func <a href="http://localhost:6060/src/crypto/x509/x509.go?s=49450:49567#L1558">CreateCertificate</a></h2>
  209. <pre>func CreateCertificate(rand <a href="../../io/index.html">io</a>.<a href="../../io/index.html#Reader">Reader</a>, template, parent *<a href="index.html#Certificate">Certificate</a>, pub, priv interface{}) (cert []<a href="../../builtin/index.html#byte">byte</a>, err <a href="../../builtin/index.html#error">error</a>)</pre>
  210. <p>
  211. CreateCertificate creates a new certificate based on a template. The
  212. following members of template are used: SerialNumber, Subject, NotBefore,
  213. NotAfter, KeyUsage, ExtKeyUsage, UnknownExtKeyUsage, BasicConstraintsValid,
  214. IsCA, MaxPathLen, SubjectKeyId, DNSNames, PermittedDNSDomainsCritical,
  215. PermittedDNSDomains, SignatureAlgorithm.
  216. </p>
  217. <p>
  218. The certificate is signed by parent. If parent is equal to template then the
  219. certificate is self-signed. The parameter pub is the public key of the
  220. signee and priv is the private key of the signer.
  221. </p>
  222. <p>
  223. The returned slice is the certificate in DER encoding.
  224. </p>
  225. <p>
  226. All keys types that are implemented via crypto.Signer are supported (This
  227. includes *rsa.PublicKey and *ecdsa.PublicKey.)
  228. </p>
  229. <h2 id="CreateCertificateRequest">func <a href="http://localhost:6060/src/crypto/x509/x509.go?s=58474:58591#L1849">CreateCertificateRequest</a></h2>
  230. <pre>func CreateCertificateRequest(rand <a href="../../io/index.html">io</a>.<a href="../../io/index.html#Reader">Reader</a>, template *<a href="index.html#CertificateRequest">CertificateRequest</a>, priv interface{}) (csr []<a href="../../builtin/index.html#byte">byte</a>, err <a href="../../builtin/index.html#error">error</a>)</pre>
  231. <p>
  232. CreateCertificateRequest creates a new certificate based on a template. The
  233. following members of template are used: Subject, Attributes,
  234. SignatureAlgorithm, Extensions, DNSNames, EmailAddresses, and IPAddresses.
  235. The private key is the private key of the signer.
  236. </p>
  237. <p>
  238. The returned slice is the certificate request in DER encoding.
  239. </p>
  240. <p>
  241. All keys types that are implemented via crypto.Signer are supported (This
  242. includes *rsa.PublicKey and *ecdsa.PublicKey.)
  243. </p>
  244. <h2 id="DecryptPEMBlock">func <a href="http://localhost:6060/src/crypto/x509/pem_decrypt.go?s=3144:3211#L105">DecryptPEMBlock</a></h2>
  245. <pre>func DecryptPEMBlock(b *<a href="../../encoding/pem/index.html">pem</a>.<a href="../../encoding/pem/index.html#Block">Block</a>, password []<a href="../../builtin/index.html#byte">byte</a>) ([]<a href="../../builtin/index.html#byte">byte</a>, <a href="../../builtin/index.html#error">error</a>)</pre>
  246. <p>
  247. DecryptPEMBlock takes a password encrypted PEM block and the password used to
  248. encrypt it and returns a slice of decrypted DER encoded bytes. It inspects
  249. the DEK-Info header to determine the algorithm used for decryption. If no
  250. DEK-Info header is present, an error is returned. If an incorrect password
  251. is detected an IncorrectPasswordError is returned. Because of deficiencies
  252. in the encrypted-PEM format, it&#39;s not always possible to detect an incorrect
  253. password. In these cases no error will be returned but the decrypted DER
  254. bytes will be random noise.
  255. </p>
  256. <h2 id="EncryptPEMBlock">func <a href="http://localhost:6060/src/crypto/x509/pem_decrypt.go?s=5073:5185#L173">EncryptPEMBlock</a></h2>
  257. <pre>func EncryptPEMBlock(rand <a href="../../io/index.html">io</a>.<a href="../../io/index.html#Reader">Reader</a>, blockType <a href="../../builtin/index.html#string">string</a>, data, password []<a href="../../builtin/index.html#byte">byte</a>, alg <a href="index.html#PEMCipher">PEMCipher</a>) (*<a href="../../encoding/pem/index.html">pem</a>.<a href="../../encoding/pem/index.html#Block">Block</a>, <a href="../../builtin/index.html#error">error</a>)</pre>
  258. <p>
  259. EncryptPEMBlock returns a PEM block of the specified type holding the
  260. given DER-encoded data encrypted with the specified algorithm and
  261. password.
  262. </p>
  263. <h2 id="IsEncryptedPEMBlock">func <a href="http://localhost:6060/src/crypto/x509/pem_decrypt.go?s=2315:2358#L89">IsEncryptedPEMBlock</a></h2>
  264. <pre>func IsEncryptedPEMBlock(b *<a href="../../encoding/pem/index.html">pem</a>.<a href="../../encoding/pem/index.html#Block">Block</a>) <a href="../../builtin/index.html#bool">bool</a></pre>
  265. <p>
  266. IsEncryptedPEMBlock returns if the PEM block is password encrypted.
  267. </p>
  268. <h2 id="MarshalECPrivateKey">func <a href="http://localhost:6060/src/crypto/x509/sec1.go?s=1008:1071#L27">MarshalECPrivateKey</a></h2>
  269. <pre>func MarshalECPrivateKey(key *<a href="../ecdsa/index.html">ecdsa</a>.<a href="../ecdsa/index.html#PrivateKey">PrivateKey</a>) ([]<a href="../../builtin/index.html#byte">byte</a>, <a href="../../builtin/index.html#error">error</a>)</pre>
  270. <p>
  271. MarshalECPrivateKey marshals an EC private key into ASN.1, DER format.
  272. </p>
  273. <h2 id="MarshalPKCS1PrivateKey">func <a href="http://localhost:6060/src/crypto/x509/pkcs1.go?s=2109:2164#L77">MarshalPKCS1PrivateKey</a></h2>
  274. <pre>func MarshalPKCS1PrivateKey(key *<a href="../rsa/index.html">rsa</a>.<a href="../rsa/index.html#PrivateKey">PrivateKey</a>) []<a href="../../builtin/index.html#byte">byte</a></pre>
  275. <p>
  276. MarshalPKCS1PrivateKey converts a private key to ASN.1 DER encoded form.
  277. </p>
  278. <h2 id="MarshalPKIXPublicKey">func <a href="http://localhost:6060/src/crypto/x509/x509.go?s=2581:2639#L81">MarshalPKIXPublicKey</a></h2>
  279. <pre>func MarshalPKIXPublicKey(pub interface{}) ([]<a href="../../builtin/index.html#byte">byte</a>, <a href="../../builtin/index.html#error">error</a>)</pre>
  280. <p>
  281. MarshalPKIXPublicKey serialises a public key to DER-encoded PKIX format.
  282. </p>
  283. <h2 id="ParseCRL">func <a href="http://localhost:6060/src/crypto/x509/x509.go?s=51681:51755#L1641">ParseCRL</a></h2>
  284. <pre>func ParseCRL(crlBytes []<a href="../../builtin/index.html#byte">byte</a>) (certList *<a href="pkix/index.html">pkix</a>.<a href="pkix/index.html#CertificateList">CertificateList</a>, err <a href="../../builtin/index.html#error">error</a>)</pre>
  285. <p>
  286. ParseCRL parses a CRL from the given bytes. It&#39;s often the case that PEM
  287. encoded CRLs will appear where they should be DER encoded, so this function
  288. will transparently handle PEM encoding as long as there isn&#39;t any leading
  289. garbage.
  290. </p>
  291. <h2 id="ParseCertificates">func <a href="http://localhost:6060/src/crypto/x509/x509.go?s=38729:38792#L1190">ParseCertificates</a></h2>
  292. <pre>func ParseCertificates(asn1Data []<a href="../../builtin/index.html#byte">byte</a>) ([]*<a href="index.html#Certificate">Certificate</a>, <a href="../../builtin/index.html#error">error</a>)</pre>
  293. <p>
  294. ParseCertificates parses one or more certificates from the given ASN.1 DER
  295. data. The certificates must be concatenated with no intermediate padding.
  296. </p>
  297. <h2 id="ParseDERCRL">func <a href="http://localhost:6060/src/crypto/x509/x509.go?s=52012:52089#L1652">ParseDERCRL</a></h2>
  298. <pre>func ParseDERCRL(derBytes []<a href="../../builtin/index.html#byte">byte</a>) (certList *<a href="pkix/index.html">pkix</a>.<a href="pkix/index.html#CertificateList">CertificateList</a>, err <a href="../../builtin/index.html#error">error</a>)</pre>
  299. <p>
  300. ParseDERCRL parses a DER encoded CRL from the given bytes.
  301. </p>
  302. <h2 id="ParseECPrivateKey">func <a href="http://localhost:6060/src/crypto/x509/sec1.go?s=823:892#L22">ParseECPrivateKey</a></h2>
  303. <pre>func ParseECPrivateKey(der []<a href="../../builtin/index.html#byte">byte</a>) (key *<a href="../ecdsa/index.html">ecdsa</a>.<a href="../ecdsa/index.html#PrivateKey">PrivateKey</a>, err <a href="../../builtin/index.html#error">error</a>)</pre>
  304. <p>
  305. ParseECPrivateKey parses an ASN.1 Elliptic Curve Private Key Structure.
  306. </p>
  307. <h2 id="ParsePKCS1PrivateKey">func <a href="http://localhost:6060/src/crypto/x509/pkcs1.go?s=945:1015#L29">ParsePKCS1PrivateKey</a></h2>
  308. <pre>func ParsePKCS1PrivateKey(der []<a href="../../builtin/index.html#byte">byte</a>) (key *<a href="../rsa/index.html">rsa</a>.<a href="../rsa/index.html#PrivateKey">PrivateKey</a>, err <a href="../../builtin/index.html#error">error</a>)</pre>
  309. <p>
  310. ParsePKCS1PrivateKey returns an RSA private key from its ASN.1 PKCS#1 DER encoded form.
  311. </p>
  312. <h2 id="ParsePKCS8PrivateKey">func <a href="http://localhost:6060/src/crypto/x509/pkcs8.go?s=626:692#L16">ParsePKCS8PrivateKey</a></h2>
  313. <pre>func ParsePKCS8PrivateKey(der []<a href="../../builtin/index.html#byte">byte</a>) (key interface{}, err <a href="../../builtin/index.html#error">error</a>)</pre>
  314. <p>
  315. ParsePKCS8PrivateKey parses an unencrypted, PKCS#8 private key. See
  316. <a href="http://www.rsa.com/rsalabs/node.asp?id=2130">http://www.rsa.com/rsalabs/node.asp?id=2130</a> and RFC5208.
  317. </p>
  318. <h2 id="ParsePKIXPublicKey">func <a href="http://localhost:6060/src/crypto/x509/x509.go?s=816:885#L29">ParsePKIXPublicKey</a></h2>
  319. <pre>func ParsePKIXPublicKey(derBytes []<a href="../../builtin/index.html#byte">byte</a>) (pub interface{}, err <a href="../../builtin/index.html#error">error</a>)</pre>
  320. <p>
  321. ParsePKIXPublicKey parses a DER encoded public key. These values are
  322. typically found in PEM blocks with &#34;BEGIN PUBLIC KEY&#34;.
  323. </p>
  324. <h2 id="CertPool">type <a href="http://localhost:6060/src/crypto/x509/cert_pool.go?s=240:361#L2">CertPool</a></h2>
  325. <pre>type CertPool struct {
  326. <span class="comment">// contains filtered or unexported fields</span>
  327. }</pre>
  328. <p>
  329. CertPool is a set of certificates.
  330. </p>
  331. <h3 id="NewCertPool">func <a href="http://localhost:6060/src/crypto/x509/cert_pool.go?s=409:437#L9">NewCertPool</a></h3>
  332. <pre>func NewCertPool() *<a href="index.html#CertPool">CertPool</a></pre>
  333. <p>
  334. NewCertPool returns a new, empty CertPool.
  335. </p>
  336. <h3 id="CertPool.AddCert">func (*CertPool) <a href="http://localhost:6060/src/crypto/x509/cert_pool.go?s=1329:1374#L46">AddCert</a></h3>
  337. <pre>func (s *<a href="index.html#CertPool">CertPool</a>) AddCert(cert *<a href="index.html#Certificate">Certificate</a>)</pre>
  338. <p>
  339. AddCert adds a certificate to a pool.
  340. </p>
  341. <h3 id="CertPool.AppendCertsFromPEM">func (*CertPool) <a href="http://localhost:6060/src/crypto/x509/cert_pool.go?s=2159:2223#L75">AppendCertsFromPEM</a></h3>
  342. <pre>func (s *<a href="index.html#CertPool">CertPool</a>) AppendCertsFromPEM(pemCerts []<a href="../../builtin/index.html#byte">byte</a>) (ok <a href="../../builtin/index.html#bool">bool</a>)</pre>
  343. <p>
  344. AppendCertsFromPEM attempts to parse a series of PEM encoded certificates.
  345. It appends any certificates found to s and reports whether any certificates
  346. were successfully parsed.
  347. </p>
  348. <p>
  349. On many Linux systems, /etc/ssl/cert.pem will contain the system wide set
  350. of root CAs in a format suitable for this function.
  351. </p>
  352. <h3 id="CertPool.Subjects">func (*CertPool) <a href="http://localhost:6060/src/crypto/x509/cert_pool.go?s=2650:2694#L100">Subjects</a></h3>
  353. <pre>func (s *<a href="index.html#CertPool">CertPool</a>) Subjects() (res [][]<a href="../../builtin/index.html#byte">byte</a>)</pre>
  354. <p>
  355. Subjects returns a list of the DER-encoded subjects of
  356. all of the certificates in the pool.
  357. </p>
  358. <h2 id="Certificate">type <a href="http://localhost:6060/src/crypto/x509/x509.go?s=15246:18151#L477">Certificate</a></h2>
  359. <pre>type Certificate struct {
  360. Raw []<a href="../../builtin/index.html#byte">byte</a> <span class="comment">// Complete ASN.1 DER content (certificate, signature algorithm and signature).</span>
  361. RawTBSCertificate []<a href="../../builtin/index.html#byte">byte</a> <span class="comment">// Certificate part of raw ASN.1 DER content.</span>
  362. RawSubjectPublicKeyInfo []<a href="../../builtin/index.html#byte">byte</a> <span class="comment">// DER encoded SubjectPublicKeyInfo.</span>
  363. RawSubject []<a href="../../builtin/index.html#byte">byte</a> <span class="comment">// DER encoded Subject</span>
  364. RawIssuer []<a href="../../builtin/index.html#byte">byte</a> <span class="comment">// DER encoded Issuer</span>
  365. Signature []<a href="../../builtin/index.html#byte">byte</a>
  366. SignatureAlgorithm <a href="index.html#SignatureAlgorithm">SignatureAlgorithm</a>
  367. PublicKeyAlgorithm <a href="index.html#PublicKeyAlgorithm">PublicKeyAlgorithm</a>
  368. PublicKey interface{}
  369. Version <a href="../../builtin/index.html#int">int</a>
  370. SerialNumber *<a href="../../math/big/index.html">big</a>.<a href="../../math/big/index.html#Int">Int</a>
  371. Issuer <a href="pkix/index.html">pkix</a>.<a href="pkix/index.html#Name">Name</a>
  372. Subject <a href="pkix/index.html">pkix</a>.<a href="pkix/index.html#Name">Name</a>
  373. NotBefore, NotAfter <a href="../../time/index.html">time</a>.<a href="../../time/index.html#Time">Time</a> <span class="comment">// Validity bounds.</span>
  374. KeyUsage <a href="index.html#KeyUsage">KeyUsage</a>
  375. <span class="comment">// Extensions contains raw X.509 extensions. When parsing certificates,</span>
  376. <span class="comment">// this can be used to extract non-critical extensions that are not</span>
  377. <span class="comment">// parsed by this package. When marshaling certificates, the Extensions</span>
  378. <span class="comment">// field is ignored, see ExtraExtensions.</span>
  379. Extensions []<a href="pkix/index.html">pkix</a>.<a href="pkix/index.html#Extension">Extension</a>
  380. <span class="comment">// ExtraExtensions contains extensions to be copied, raw, into any</span>
  381. <span class="comment">// marshaled certificates. Values override any extensions that would</span>
  382. <span class="comment">// otherwise be produced based on the other fields. The ExtraExtensions</span>
  383. <span class="comment">// field is not populated when parsing certificates, see Extensions.</span>
  384. ExtraExtensions []<a href="pkix/index.html">pkix</a>.<a href="pkix/index.html#Extension">Extension</a>
  385. <span class="comment">// UnhandledCriticalExtensions contains a list of extension IDs that</span>
  386. <span class="comment">// were not (fully) processed when parsing. Verify will fail if this</span>
  387. <span class="comment">// slice is non-empty, unless verification is delegated to an OS</span>
  388. <span class="comment">// library which understands all the critical extensions.</span>
  389. <span class="comment">//</span>
  390. <span class="comment">// Users can access these extensions using Extensions and can remove</span>
  391. <span class="comment">// elements from this slice if they believe that they have been</span>
  392. <span class="comment">// handled.</span>
  393. UnhandledCriticalExtensions []<a href="../../encoding/asn1/index.html">asn1</a>.<a href="../../encoding/asn1/index.html#ObjectIdentifier">ObjectIdentifier</a>
  394. ExtKeyUsage []<a href="index.html#ExtKeyUsage">ExtKeyUsage</a> <span class="comment">// Sequence of extended key usages.</span>
  395. UnknownExtKeyUsage []<a href="../../encoding/asn1/index.html">asn1</a>.<a href="../../encoding/asn1/index.html#ObjectIdentifier">ObjectIdentifier</a> <span class="comment">// Encountered extended key usages unknown to this package.</span>
  396. BasicConstraintsValid <a href="../../builtin/index.html#bool">bool</a> <span class="comment">// if true then the next two fields are valid.</span>
  397. IsCA <a href="../../builtin/index.html#bool">bool</a>
  398. MaxPathLen <a href="../../builtin/index.html#int">int</a>
  399. <span class="comment">// MaxPathLenZero indicates that BasicConstraintsValid==true and</span>
  400. <span class="comment">// MaxPathLen==0 should be interpreted as an actual maximum path length</span>
  401. <span class="comment">// of zero. Otherwise, that combination is interpreted as MaxPathLen</span>
  402. <span class="comment">// not being set.</span>
  403. MaxPathLenZero <a href="../../builtin/index.html#bool">bool</a>
  404. SubjectKeyId []<a href="../../builtin/index.html#byte">byte</a>
  405. AuthorityKeyId []<a href="../../builtin/index.html#byte">byte</a>
  406. <span class="comment">// RFC 5280, 4.2.2.1 (Authority Information Access)</span>
  407. OCSPServer []<a href="../../builtin/index.html#string">string</a>
  408. IssuingCertificateURL []<a href="../../builtin/index.html#string">string</a>
  409. <span class="comment">// Subject Alternate Name values</span>
  410. DNSNames []<a href="../../builtin/index.html#string">string</a>
  411. EmailAddresses []<a href="../../builtin/index.html#string">string</a>
  412. IPAddresses []<a href="../../net/index.html">net</a>.<a href="../../net/index.html#IP">IP</a>
  413. <span class="comment">// Name constraints</span>
  414. PermittedDNSDomainsCritical <a href="../../builtin/index.html#bool">bool</a> <span class="comment">// if true then the name constraints are marked critical.</span>
  415. PermittedDNSDomains []<a href="../../builtin/index.html#string">string</a>
  416. <span class="comment">// CRL Distribution Points</span>
  417. CRLDistributionPoints []<a href="../../builtin/index.html#string">string</a>
  418. PolicyIdentifiers []<a href="../../encoding/asn1/index.html">asn1</a>.<a href="../../encoding/asn1/index.html#ObjectIdentifier">ObjectIdentifier</a>
  419. }</pre>
  420. <p>
  421. A Certificate represents an X.509 certificate.
  422. </p>
  423. <h3 id="ParseCertificate">func <a href="http://localhost:6060/src/crypto/x509/x509.go?s=38293:38353#L1175">ParseCertificate</a></h3>
  424. <pre>func ParseCertificate(asn1Data []<a href="../../builtin/index.html#byte">byte</a>) (*<a href="index.html#Certificate">Certificate</a>, <a href="../../builtin/index.html#error">error</a>)</pre>
  425. <p>
  426. ParseCertificate parses a single certificate from the given ASN.1 DER data.
  427. </p>
  428. <h3 id="Certificate.CheckCRLSignature">func (*Certificate) <a href="http://localhost:6060/src/crypto/x509/x509.go?s=24688:24766#L724">CheckCRLSignature</a></h3>
  429. <pre>func (c *<a href="index.html#Certificate">Certificate</a>) CheckCRLSignature(crl *<a href="pkix/index.html">pkix</a>.<a href="pkix/index.html#CertificateList">CertificateList</a>) (err <a href="../../builtin/index.html#error">error</a>)</pre>
  430. <p>
  431. CheckCRLSignature checks that the signature in crl is from c.
  432. </p>
  433. <h3 id="Certificate.CheckSignature">func (*Certificate) <a href="http://localhost:6060/src/crypto/x509/x509.go?s=22530:22629#L656">CheckSignature</a></h3>
  434. <pre>func (c *<a href="index.html#Certificate">Certificate</a>) CheckSignature(algo <a href="index.html#SignatureAlgorithm">SignatureAlgorithm</a>, signed, signature []<a href="../../builtin/index.html#byte">byte</a>) (err <a href="../../builtin/index.html#error">error</a>)</pre>
  435. <p>
  436. CheckSignature verifies that signature is a valid signature over signed from
  437. c&#39;s public key.
  438. </p>
  439. <h3 id="Certificate.CheckSignatureFrom">func (*Certificate) <a href="http://localhost:6060/src/crypto/x509/x509.go?s=21462:21535#L628">CheckSignatureFrom</a></h3>
  440. <pre>func (c *<a href="index.html#Certificate">Certificate</a>) CheckSignatureFrom(parent *<a href="index.html#Certificate">Certificate</a>) (err <a href="../../builtin/index.html#error">error</a>)</pre>
  441. <p>
  442. CheckSignatureFrom verifies that the signature on c is a valid signature
  443. from parent.
  444. </p>
  445. <h3 id="Certificate.CreateCRL">func (*Certificate) <a href="http://localhost:6060/src/crypto/x509/x509.go?s=52453:52610#L1664">CreateCRL</a></h3>
  446. <pre>func (c *<a href="index.html#Certificate">Certificate</a>) CreateCRL(rand <a href="../../io/index.html">io</a>.<a href="../../io/index.html#Reader">Reader</a>, priv interface{}, revokedCerts []<a href="pkix/index.html">pkix</a>.<a href="pkix/index.html#RevokedCertificate">RevokedCertificate</a>, now, expiry <a href="../../time/index.html">time</a>.<a href="../../time/index.html#Time">Time</a>) (crlBytes []<a href="../../builtin/index.html#byte">byte</a>, err <a href="../../builtin/index.html#error">error</a>)</pre>
  447. <p>
  448. CreateCRL returns a DER encoded CRL, signed by this Certificate, that
  449. contains the given list of revoked certificates.
  450. </p>
  451. <h3 id="Certificate.Equal">func (*Certificate) <a href="http://localhost:6060/src/crypto/x509/x509.go?s=18990:19042#L573">Equal</a></h3>
  452. <pre>func (c *<a href="index.html#Certificate">Certificate</a>) Equal(other *<a href="index.html#Certificate">Certificate</a>) <a href="../../builtin/index.html#bool">bool</a></pre>
  453. <h3 id="Certificate.Verify">func (*Certificate) <a href="http://localhost:6060/src/crypto/x509/verify.go?s=7315:7400#L207">Verify</a></h3>
  454. <pre>func (c *<a href="index.html#Certificate">Certificate</a>) Verify(opts <a href="index.html#VerifyOptions">VerifyOptions</a>) (chains [][]*<a href="index.html#Certificate">Certificate</a>, err <a href="../../builtin/index.html#error">error</a>)</pre>
  455. <p>
  456. Verify attempts to verify c by building one or more chains from c to a
  457. certificate in opts.Roots, using certificates in opts.Intermediates if
  458. needed. If successful, it returns one or more chains where the first
  459. element of the chain is c and the last element is from opts.Roots.
  460. </p>
  461. <p>
  462. If opts.Roots is nil and system roots are unavailable the returned error
  463. will be of type SystemRootsError.
  464. </p>
  465. <p>
  466. WARNING: this doesn&#39;t do any revocation checking.
  467. </p>
  468. <div id="example_Certificate_Verify" class="toggle">
  469. <div class="collapsed">
  470. <p class="exampleHeading toggleButton"><span class="text">Example</span></p>
  471. </div>
  472. <div class="expanded">
  473. <p class="exampleHeading toggleButton"><span class="text">Example</span></p>
  474. <p>Code:</p>
  475. <pre class="code">
  476. <span class="comment">// Verifying with a custom list of root certificates.</span>
  477. const rootPEM = `
  478. -----BEGIN CERTIFICATE-----
  479. MIIEBDCCAuygAwIBAgIDAjppMA0GCSqGSIb3DQEBBQUAMEIxCzAJBgNVBAYTAlVT
  480. MRYwFAYDVQQKEw1HZW9UcnVzdCBJbmMuMRswGQYDVQQDExJHZW9UcnVzdCBHbG9i
  481. YWwgQ0EwHhcNMTMwNDA1MTUxNTU1WhcNMTUwNDA0MTUxNTU1WjBJMQswCQYDVQQG
  482. EwJVUzETMBEGA1UEChMKR29vZ2xlIEluYzElMCMGA1UEAxMcR29vZ2xlIEludGVy
  483. bmV0IEF1dGhvcml0eSBHMjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB
  484. AJwqBHdc2FCROgajguDYUEi8iT/xGXAaiEZ+4I/F8YnOIe5a/mENtzJEiaB0C1NP
  485. VaTOgmKV7utZX8bhBYASxF6UP7xbSDj0U/ck5vuR6RXEz/RTDfRK/J9U3n2+oGtv
  486. h8DQUB8oMANA2ghzUWx//zo8pzcGjr1LEQTrfSTe5vn8MXH7lNVg8y5Kr0LSy+rE
  487. ahqyzFPdFUuLH8gZYR/Nnag+YyuENWllhMgZxUYi+FOVvuOAShDGKuy6lyARxzmZ
  488. EASg8GF6lSWMTlJ14rbtCMoU/M4iarNOz0YDl5cDfsCx3nuvRTPPuj5xt970JSXC
  489. DTWJnZ37DhF5iR43xa+OcmkCAwEAAaOB+zCB+DAfBgNVHSMEGDAWgBTAephojYn7
  490. qwVkDBF9qn1luMrMTjAdBgNVHQ4EFgQUSt0GFhu89mi1dvWBtrtiGrpagS8wEgYD
  491. VR0TAQH/BAgwBgEB/wIBADAOBgNVHQ8BAf8EBAMCAQYwOgYDVR0fBDMwMTAvoC2g
  492. K4YpaHR0cDovL2NybC5nZW90cnVzdC5jb20vY3Jscy9ndGdsb2JhbC5jcmwwPQYI
  493. KwYBBQUHAQEEMTAvMC0GCCsGAQUFBzABhiFodHRwOi8vZ3RnbG9iYWwtb2NzcC5n
  494. ZW90cnVzdC5jb20wFwYDVR0gBBAwDjAMBgorBgEEAdZ5AgUBMA0GCSqGSIb3DQEB
  495. BQUAA4IBAQA21waAESetKhSbOHezI6B1WLuxfoNCunLaHtiONgaX4PCVOzf9G0JY
  496. /iLIa704XtE7JW4S615ndkZAkNoUyHgN7ZVm2o6Gb4ChulYylYbc3GrKBIxbf/a/
  497. zG+FA1jDaFETzf3I93k9mTXwVqO94FntT0QJo544evZG0R0SnU++0ED8Vf4GXjza
  498. HFa9llF7b1cq26KqltyMdMKVvvBulRP/F/A8rLIQjcxz++iPAsbw+zOzlTvjwsto
  499. WHPbqCRiOwY1nQ2pM714A5AuTHhdUDqB1O6gyHA43LL5Z/qHQF1hwFGPa4NrzQU6
  500. yuGnBXj8ytqU0CwIPX4WecigUCAkVDNx
  501. -----END CERTIFICATE-----`
  502. const certPEM = `
  503. -----BEGIN CERTIFICATE-----
  504. MIIDujCCAqKgAwIBAgIIE31FZVaPXTUwDQYJKoZIhvcNAQEFBQAwSTELMAkGA1UE
  505. BhMCVVMxEzARBgNVBAoTCkdvb2dsZSBJbmMxJTAjBgNVBAMTHEdvb2dsZSBJbnRl
  506. cm5ldCBBdXRob3JpdHkgRzIwHhcNMTQwMTI5MTMyNzQzWhcNMTQwNTI5MDAwMDAw
  507. WjBpMQswCQYDVQQGEwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwN
  508. TW91bnRhaW4gVmlldzETMBEGA1UECgwKR29vZ2xlIEluYzEYMBYGA1UEAwwPbWFp
  509. bC5nb29nbGUuY29tMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEfRrObuSW5T7q
  510. 5CnSEqefEmtH4CCv6+5EckuriNr1CjfVvqzwfAhopXkLrq45EQm8vkmf7W96XJhC
  511. 7ZM0dYi1/qOCAU8wggFLMB0GA1UdJQQWMBQGCCsGAQUFBwMBBggrBgEFBQcDAjAa
  512. BgNVHREEEzARgg9tYWlsLmdvb2dsZS5jb20wCwYDVR0PBAQDAgeAMGgGCCsGAQUF
  513. BwEBBFwwWjArBggrBgEFBQcwAoYfaHR0cDovL3BraS5nb29nbGUuY29tL0dJQUcy
  514. LmNydDArBggrBgEFBQcwAYYfaHR0cDovL2NsaWVudHMxLmdvb2dsZS5jb20vb2Nz
  515. cDAdBgNVHQ4EFgQUiJxtimAuTfwb+aUtBn5UYKreKvMwDAYDVR0TAQH/BAIwADAf
  516. BgNVHSMEGDAWgBRK3QYWG7z2aLV29YG2u2IaulqBLzAXBgNVHSAEEDAOMAwGCisG
  517. AQQB1nkCBQEwMAYDVR0fBCkwJzAloCOgIYYfaHR0cDovL3BraS5nb29nbGUuY29t
  518. L0dJQUcyLmNybDANBgkqhkiG9w0BAQUFAAOCAQEAH6RYHxHdcGpMpFE3oxDoFnP+
  519. gtuBCHan2yE2GRbJ2Cw8Lw0MmuKqHlf9RSeYfd3BXeKkj1qO6TVKwCh+0HdZk283
  520. TZZyzmEOyclm3UGFYe82P/iDFt+CeQ3NpmBg+GoaVCuWAARJN/KfglbLyyYygcQq
  521. 0SgeDh8dRKUiaW3HQSoYvTvdTuqzwK4CXsr3b5/dAOY8uMuG/IAR3FgwTbZ1dtoW
  522. RvOTa8hYiU6A475WuZKyEHcwnGYe57u2I2KbMgcKjPniocj4QzgYsVAVKW3IwaOh
  523. yE+vPxsiUkvQHdO2fojCkY8jg70jxM+gu59tPDNbw3Uh/2Ij310FgTHsnGQMyA==
  524. -----END CERTIFICATE-----`
  525. <span class="comment">// First, create the set of root certificates. For this example we only</span>
  526. <span class="comment">// have one. It&#39;s also possible to omit this in order to use the</span>
  527. <span class="comment">// default root set of the current operating system.</span>
  528. roots := x509.NewCertPool()
  529. ok := roots.AppendCertsFromPEM([]byte(rootPEM))
  530. if !ok {
  531. panic(&#34;failed to parse root certificate&#34;)
  532. }
  533. block, _ := pem.Decode([]byte(certPEM))
  534. if block == nil {
  535. panic(&#34;failed to parse certificate PEM&#34;)
  536. }
  537. cert, err := x509.ParseCertificate(block.Bytes)
  538. if err != nil {
  539. panic(&#34;failed to parse certificate: &#34; + err.Error())
  540. }
  541. opts := x509.VerifyOptions{
  542. DNSName: &#34;mail.google.com&#34;,
  543. Roots: roots,
  544. }
  545. if _, err := cert.Verify(opts); err != nil {
  546. panic(&#34;failed to verify certificate: &#34; + err.Error())
  547. }
  548. </pre>
  549. </div>
  550. </div>
  551. <h3 id="Certificate.VerifyHostname">func (*Certificate) <a href="http://localhost:6060/src/crypto/x509/verify.go?s=12003:12055#L398">VerifyHostname</a></h3>
  552. <pre>func (c *<a href="index.html#Certificate">Certificate</a>) VerifyHostname(h <a href="../../builtin/index.html#string">string</a>) <a href="../../builtin/index.html#error">error</a></pre>
  553. <p>
  554. VerifyHostname returns nil if c is a valid certificate for the named host.
  555. Otherwise it returns an error describing the mismatch.
  556. </p>
  557. <h2 id="CertificateInvalidError">type <a href="http://localhost:6060/src/crypto/x509/verify.go?s=1130:1212#L30">CertificateInvalidError</a></h2>
  558. <pre>type CertificateInvalidError struct {
  559. Cert *<a href="index.html#Certificate">Certificate</a>
  560. Reason <a href="index.html#InvalidReason">InvalidReason</a>
  561. }</pre>
  562. <p>
  563. CertificateInvalidError results when an odd error occurs. Users of this
  564. library probably want to handle all these errors uniformly.
  565. </p>
  566. <h3 id="CertificateInvalidError.Error">func (CertificateInvalidError) <a href="http://localhost:6060/src/crypto/x509/verify.go?s=1214:1261#L35">Error</a></h3>
  567. <pre>func (e <a href="index.html#CertificateInvalidError">CertificateInvalidError</a>) Error() <a href="../../builtin/index.html#string">string</a></pre>
  568. <h2 id="CertificateRequest">type <a href="http://localhost:6060/src/crypto/x509/x509.go?s=53971:55284#L1718">CertificateRequest</a></h2>
  569. <pre>type CertificateRequest struct {
  570. Raw []<a href="../../builtin/index.html#byte">byte</a> <span class="comment">// Complete ASN.1 DER content (CSR, signature algorithm and signature).</span>
  571. RawTBSCertificateRequest []<a href="../../builtin/index.html#byte">byte</a> <span class="comment">// Certificate request info part of raw ASN.1 DER content.</span>
  572. RawSubjectPublicKeyInfo []<a href="../../builtin/index.html#byte">byte</a> <span class="comment">// DER encoded SubjectPublicKeyInfo.</span>
  573. RawSubject []<a href="../../builtin/index.html#byte">byte</a> <span class="comment">// DER encoded Subject.</span>
  574. Version <a href="../../builtin/index.html#int">int</a>
  575. Signature []<a href="../../builtin/index.html#byte">byte</a>
  576. SignatureAlgorithm <a href="index.html#SignatureAlgorithm">SignatureAlgorithm</a>
  577. PublicKeyAlgorithm <a href="index.html#PublicKeyAlgorithm">PublicKeyAlgorithm</a>
  578. PublicKey interface{}
  579. Subject <a href="pkix/index.html">pkix</a>.<a href="pkix/index.html#Name">Name</a>
  580. <span class="comment">// Attributes is the dried husk of a bug and shouldn&#39;t be used.</span>
  581. Attributes []<a href="pkix/index.html">pkix</a>.<a href="pkix/index.html#AttributeTypeAndValueSET">AttributeTypeAndValueSET</a>
  582. <span class="comment">// Extensions contains raw X.509 extensions. When parsing CSRs, this</span>
  583. <span class="comment">// can be used to extract extensions that are not parsed by this</span>
  584. <span class="comment">// package.</span>
  585. Extensions []<a href="pkix/index.html">pkix</a>.<a href="pkix/index.html#Extension">Extension</a>
  586. <span class="comment">// ExtraExtensions contains extensions to be copied, raw, into any</span>
  587. <span class="comment">// marshaled CSR. Values override any extensions that would otherwise</span>
  588. <span class="comment">// be produced based on the other fields but are overridden by any</span>
  589. <span class="comment">// extensions specified in Attributes.</span>
  590. <span class="comment">//</span>
  591. <span class="comment">// The ExtraExtensions field is not populated when parsing CSRs, see</span>
  592. <span class="comment">// Extensions.</span>
  593. ExtraExtensions []<a href="pkix/index.html">pkix</a>.<a href="pkix/index.html#Extension">Extension</a>
  594. <span class="comment">// Subject Alternate Name values.</span>
  595. DNSNames []<a href="../../builtin/index.html#string">string</a>
  596. EmailAddresses []<a href="../../builtin/index.html#string">string</a>
  597. IPAddresses []<a href="../../net/index.html">net</a>.<a href="../../net/index.html#IP">IP</a>
  598. }</pre>
  599. <p>
  600. CertificateRequest represents a PKCS #10, certificate signature request.
  601. </p>
  602. <h3 id="ParseCertificateRequest">func <a href="http://localhost:6060/src/crypto/x509/x509.go?s=62307:62381#L1998">ParseCertificateRequest</a></h3>
  603. <pre>func ParseCertificateRequest(asn1Data []<a href="../../builtin/index.html#byte">byte</a>) (*<a href="index.html#CertificateRequest">CertificateRequest</a>, <a href="../../builtin/index.html#error">error</a>)</pre>
  604. <p>
  605. ParseCertificateRequest parses a single certificate request from the
  606. given ASN.1 DER data.
  607. </p>
  608. <h3 id="CertificateRequest.CheckSignature">func (*CertificateRequest) <a href="http://localhost:6060/src/crypto/x509/x509.go?s=64088:64145#L2059">CheckSignature</a></h3>
  609. <pre>func (c *<a href="index.html#CertificateRequest">CertificateRequest</a>) CheckSignature() (err <a href="../../builtin/index.html#error">error</a>)</pre>
  610. <p>
  611. CheckSignature verifies that the signature on c is a valid signature
  612. </p>
  613. <h2 id="ConstraintViolationError">type <a href="http://localhost:6060/src/crypto/x509/x509.go?s=18807:18845#L567">ConstraintViolationError</a></h2>
  614. <pre>type ConstraintViolationError struct{}</pre>
  615. <p>
  616. ConstraintViolationError results when a requested usage is not permitted by
  617. a certificate. For example: checking a signature when the public key isn&#39;t a
  618. certificate signing key.
  619. </p>
  620. <h3 id="ConstraintViolationError.Error">func (ConstraintViolationError) <a href="http://localhost:6060/src/crypto/x509/x509.go?s=18847:18893#L569">Error</a></h3>
  621. <pre>func (<a href="index.html#ConstraintViolationError">ConstraintViolationError</a>) Error() <a href="../../builtin/index.html#string">string</a></pre>
  622. <h2 id="ExtKeyUsage">type <a href="http://localhost:6060/src/crypto/x509/x509.go?s=13566:13586#L422">ExtKeyUsage</a></h2>
  623. <pre>type ExtKeyUsage <a href="../../builtin/index.html#int">int</a></pre>
  624. <p>
  625. ExtKeyUsage represents an extended set of actions that are valid for a given key.
  626. Each of the ExtKeyUsage* constants define a unique action.
  627. </p>
  628. <pre>const (
  629. <span id="ExtKeyUsageAny">ExtKeyUsageAny</span> <a href="index.html#ExtKeyUsage">ExtKeyUsage</a> = <a href="../../builtin/index.html#iota">iota</a>
  630. <span id="ExtKeyUsageServerAuth">ExtKeyUsageServerAuth</span>
  631. <span id="ExtKeyUsageClientAuth">ExtKeyUsageClientAuth</span>
  632. <span id="ExtKeyUsageCodeSigning">ExtKeyUsageCodeSigning</span>
  633. <span id="ExtKeyUsageEmailProtection">ExtKeyUsageEmailProtection</span>
  634. <span id="ExtKeyUsageIPSECEndSystem">ExtKeyUsageIPSECEndSystem</span>
  635. <span id="ExtKeyUsageIPSECTunnel">ExtKeyUsageIPSECTunnel</span>
  636. <span id="ExtKeyUsageIPSECUser">ExtKeyUsageIPSECUser</span>
  637. <span id="ExtKeyUsageTimeStamping">ExtKeyUsageTimeStamping</span>
  638. <span id="ExtKeyUsageOCSPSigning">ExtKeyUsageOCSPSigning</span>
  639. <span id="ExtKeyUsageMicrosoftServerGatedCrypto">ExtKeyUsageMicrosoftServerGatedCrypto</span>
  640. <span id="ExtKeyUsageNetscapeServerGatedCrypto">ExtKeyUsageNetscapeServerGatedCrypto</span>
  641. )</pre>
  642. <h2 id="HostnameError">type <a href="http://localhost:6060/src/crypto/x509/verify.go?s=1903:1978#L53">HostnameError</a></h2>
  643. <pre>type HostnameError struct {
  644. Certificate *<a href="index.html#Certificate">Certificate</a>
  645. Host <a href="../../builtin/index.html#string">string</a>
  646. }</pre>
  647. <p>
  648. HostnameError results when the set of authorized names doesn&#39;t match the
  649. requested name.
  650. </p>
  651. <h3 id="HostnameError.Error">func (HostnameError) <a href="http://localhost:6060/src/crypto/x509/verify.go?s=1980:2017#L58">Error</a></h3>
  652. <pre>func (h <a href="index.html#HostnameError">HostnameError</a>) Error() <a href="../../builtin/index.html#string">string</a></pre>
  653. <h2 id="InsecureAlgorithmError">type <a href="http://localhost:6060/src/crypto/x509/x509.go?s=18421:18467#L558">InsecureAlgorithmError</a></h2>
  654. <pre>type InsecureAlgorithmError <a href="index.html#SignatureAlgorithm">SignatureAlgorithm</a></pre>
  655. <p>
  656. An InsecureAlgorithmError
  657. </p>
  658. <h3 id="InsecureAlgorithmError.Error">func (InsecureAlgorithmError) <a href="http://localhost:6060/src/crypto/x509/x509.go?s=18469:18515#L560">Error</a></h3>
  659. <pre>func (e <a href="index.html#InsecureAlgorithmError">InsecureAlgorithmError</a>) Error() <a href="../../builtin/index.html#string">string</a></pre>
  660. <h2 id="InvalidReason">type <a href="http://localhost:6060/src/crypto/x509/verify.go?s=256:278#L7">InvalidReason</a></h2>
  661. <pre>type InvalidReason <a href="../../builtin/index.html#int">int</a></pre>
  662. <pre>const (
  663. <span class="comment">// NotAuthorizedToSign results when a certificate is signed by another</span>
  664. <span class="comment">// which isn&#39;t marked as a CA certificate.</span>
  665. <span id="NotAuthorizedToSign">NotAuthorizedToSign</span> <a href="index.html#InvalidReason">InvalidReason</a> = <a href="../../builtin/index.html#iota">iota</a>
  666. <span class="comment">// Expired results when a certificate has expired, based on the time</span>
  667. <span class="comment">// given in the VerifyOptions.</span>
  668. <span id="Expired">Expired</span>
  669. <span class="comment">// CANotAuthorizedForThisName results when an intermediate or root</span>
  670. <span class="comment">// certificate has a name constraint which doesn&#39;t include the name</span>
  671. <span class="comment">// being checked.</span>
  672. <span id="CANotAuthorizedForThisName">CANotAuthorizedForThisName</span>
  673. <span class="comment">// TooManyIntermediates results when a path length constraint is</span>
  674. <span class="comment">// violated.</span>
  675. <span id="TooManyIntermediates">TooManyIntermediates</span>
  676. <span class="comment">// IncompatibleUsage results when the certificate&#39;s key usage indicates</span>
  677. <span class="comment">// that it may only be used for a different purpose.</span>
  678. <span id="IncompatibleUsage">IncompatibleUsage</span>
  679. )</pre>
  680. <h2 id="KeyUsage">type <a href="http://localhost:6060/src/crypto/x509/x509.go?s=11479:11496#L379">KeyUsage</a></h2>
  681. <pre>type KeyUsage <a href="../../builtin/index.html#int">int</a></pre>
  682. <p>
  683. KeyUsage represents the set of actions that are valid for a given key. It&#39;s
  684. a bitmap of the KeyUsage* constants.
  685. </p>
  686. <pre>const (
  687. <span id="KeyUsageDigitalSignature">KeyUsageDigitalSignature</span> <a href="index.html#KeyUsage">KeyUsage</a> = 1 &lt;&lt; <a href="../../builtin/index.html#iota">iota</a>
  688. <span id="KeyUsageContentCommitment">KeyUsageContentCommitment</span>
  689. <span id="KeyUsageKeyEncipherment">KeyUsageKeyEncipherment</span>
  690. <span id="KeyUsageDataEncipherment">KeyUsageDataEncipherment</span>
  691. <span id="KeyUsageKeyAgreement">KeyUsageKeyAgreement</span>
  692. <span id="KeyUsageCertSign">KeyUsageCertSign</span>
  693. <span id="KeyUsageCRLSign">KeyUsageCRLSign</span>
  694. <span id="KeyUsageEncipherOnly">KeyUsageEncipherOnly</span>
  695. <span id="KeyUsageDecipherOnly">KeyUsageDecipherOnly</span>
  696. )</pre>
  697. <h2 id="PEMCipher">type <a href="http://localhost:6060/src/crypto/x509/pem_decrypt.go?s=472:490#L13">PEMCipher</a></h2>
  698. <pre>type PEMCipher <a href="../../builtin/index.html#int">int</a></pre>
  699. <pre>const (
  700. <span id="PEMCipherDES">PEMCipherDES</span> <a href="index.html#PEMCipher">PEMCipher</a>
  701. <span id="PEMCipher3DES">PEMCipher3DES</span>
  702. <span id="PEMCipherAES128">PEMCipherAES128</span>
  703. <span id="PEMCipherAES192">PEMCipherAES192</span>
  704. <span id="PEMCipherAES256">PEMCipherAES256</span>
  705. )</pre>
  706. <p>
  707. Possible values for the EncryptPEMBlock encryption algorithm.
  708. </p>
  709. <h2 id="PublicKeyAlgorithm">type <a href="http://localhost:6060/src/crypto/x509/x509.go?s=5065:5092#L190">PublicKeyAlgorithm</a></h2>
  710. <pre>type PublicKeyAlgorithm <a href="../../builtin/index.html#int">int</a></pre>
  711. <pre>const (
  712. <span id="UnknownPublicKeyAlgorithm">UnknownPublicKeyAlgorithm</span> <a href="index.html#PublicKeyAlgorithm">PublicKeyAlgorithm</a> = <a href="../../builtin/index.html#iota">iota</a>
  713. <span id="RSA">RSA</span>
  714. <span id="DSA">DSA</span>
  715. <span id="ECDSA">ECDSA</span>
  716. )</pre>
  717. <h2 id="SignatureAlgorithm">type <a href="http://localhost:6060/src/crypto/x509/x509.go?s=4230:4257#L150">SignatureAlgorithm</a></h2>
  718. <pre>type SignatureAlgorithm <a href="../../builtin/index.html#int">int</a></pre>
  719. <pre>const (
  720. <span id="UnknownSignatureAlgorithm">UnknownSignatureAlgorithm</span> <a href="index.html#SignatureAlgorithm">SignatureAlgorithm</a> = <a href="../../builtin/index.html#iota">iota</a>
  721. <span id="MD2WithRSA">MD2WithRSA</span>
  722. <span id="MD5WithRSA">MD5WithRSA</span>
  723. <span id="SHA1WithRSA">SHA1WithRSA</span>
  724. <span id="SHA256WithRSA">SHA256WithRSA</span>
  725. <span id="SHA384WithRSA">SHA384WithRSA</span>
  726. <span id="SHA512WithRSA">SHA512WithRSA</span>
  727. <span id="DSAWithSHA1">DSAWithSHA1</span>
  728. <span id="DSAWithSHA256">DSAWithSHA256</span>
  729. <span id="ECDSAWithSHA1">ECDSAWithSHA1</span>
  730. <span id="ECDSAWithSHA256">ECDSAWithSHA256</span>
  731. <span id="ECDSAWithSHA384">ECDSAWithSHA384</span>
  732. <span id="ECDSAWithSHA512">ECDSAWithSHA512</span>
  733. )</pre>
  734. <h3 id="SignatureAlgorithm.String">func (SignatureAlgorithm) <a href="http://localhost:6060/src/crypto/x509/x509.go?s=4910:4956#L183">String</a></h3>
  735. <pre>func (algo <a href="index.html#SignatureAlgorithm">SignatureAlgorithm</a>) String() <a href="../../builtin/index.html#string">string</a></pre>
  736. <h2 id="SystemRootsError">type <a href="http://localhost:6060/src/crypto/x509/verify.go?s=3548:3578#L110">SystemRootsError</a></h2>
  737. <pre>type SystemRootsError struct{}</pre>
  738. <p>
  739. SystemRootsError results when we fail to load the system root certificates.
  740. </p>
  741. <h3 id="SystemRootsError.Error">func (SystemRootsError) <a href="http://localhost:6060/src/crypto/x509/verify.go?s=3580:3618#L112">Error</a></h3>
  742. <pre>func (<a href="index.html#SystemRootsError">SystemRootsError</a>) Error() <a href="../../builtin/index.html#string">string</a></pre>
  743. <h2 id="UnhandledCriticalExtension">type <a href="http://localhost:6060/src/crypto/x509/x509.go?s=24929:24969#L729">UnhandledCriticalExtension</a></h2>
  744. <pre>type UnhandledCriticalExtension struct{}</pre>
  745. <h3 id="UnhandledCriticalExtension.Error">func (UnhandledCriticalExtension) <a href="http://localhost:6060/src/crypto/x509/x509.go?s=24971:25021#L731">Error</a></h3>
  746. <pre>func (h <a href="index.html#UnhandledCriticalExtension">UnhandledCriticalExtension</a>) Error() <a href="../../builtin/index.html#string">string</a></pre>
  747. <h2 id="UnknownAuthorityError">type <a href="http://localhost:6060/src/crypto/x509/verify.go?s=2658:2962#L84">UnknownAuthorityError</a></h2>
  748. <pre>type UnknownAuthorityError struct {
  749. <span class="comment">// contains filtered or unexported fields</span>
  750. }</pre>
  751. <p>
  752. UnknownAuthorityError results when the certificate issuer is unknown
  753. </p>
  754. <h3 id="UnknownAuthorityError.Error">func (UnknownAuthorityError) <a href="http://localhost:6060/src/crypto/x509/verify.go?s=2964:3009#L94">Error</a></h3>
  755. <pre>func (e <a href="index.html#UnknownAuthorityError">UnknownAuthorityError</a>) Error() <a href="../../builtin/index.html#string">string</a></pre>
  756. <h2 id="VerifyOptions">type <a href="http://localhost:6060/src/crypto/x509/verify.go?s=4072:4585#L122">VerifyOptions</a></h2>
  757. <pre>type VerifyOptions struct {
  758. DNSName <a href="../../builtin/index.html#string">string</a>
  759. Intermediates *<a href="index.html#CertPool">CertPool</a>
  760. Roots *<a href="index.html#CertPool">CertPool</a> <span class="comment">// if nil, the system roots are used</span>
  761. CurrentTime <a href="../../time/index.html">time</a>.<a href="../../time/index.html#Time">Time</a> <span class="comment">// if zero, the current time is used</span>
  762. <span class="comment">// KeyUsage specifies which Extended Key Usage values are acceptable.</span>
  763. <span class="comment">// An empty list means ExtKeyUsageServerAuth. Key usage is considered a</span>
  764. <span class="comment">// constraint down the chain which mirrors Windows CryptoAPI behaviour,</span>
  765. <span class="comment">// but not the spec. To accept any key usage, include ExtKeyUsageAny.</span>
  766. KeyUsages []<a href="index.html#ExtKeyUsage">ExtKeyUsage</a>
  767. }</pre>
  768. <p>
  769. VerifyOptions contains parameters for Certificate.Verify. It&#39;s a structure
  770. because other PKIX verification APIs have ended up needing many options.
  771. </p>
  772. <h2 id="pkg-subdirectories">Subdirectories</h2>
  773. <div class="pkg-dir">
  774. <table>
  775. <tr>
  776. <th class="pkg-name">Name</th>
  777. <th class="pkg-synopsis">Synopsis</th>
  778. </tr>
  779. <tr>
  780. <td colspan="2"><a href="../index.html">..</a></td>
  781. </tr>
  782. <tr>
  783. <td class="pkg-name" style="padding-left: 0px;">
  784. <a href="pkix/index.html">pkix</a>
  785. </td>
  786. <td class="pkg-synopsis">
  787. Package pkix contains shared, low level structures used for ASN.1 parsing and serialization of X.509 certificates, CRL and OCSP.
  788. </td>
  789. </tr>
  790. </table>
  791. </div>
  792. <div id="footer">
  793. Build version go1.6.<br>
  794. Except as <a href="https://developers.google.com/site-policies#restrictions">noted</a>,
  795. the content of this page is licensed under the
  796. Creative Commons Attribution 3.0 License,
  797. and code is licensed under a <a href="http://localhost:6060/LICENSE">BSD license</a>.<br>
  798. <a href="http://localhost:6060/doc/tos.html">Terms of Service</a> |
  799. <a href="http://www.google.com/intl/en/policies/privacy/">Privacy Policy</a>
  800. </div>
  801. </div><!-- .container -->
  802. </div><!-- #page -->
  803. <!-- TODO(adonovan): load these from <head> using "defer" attribute? -->
  804. <script type="text/javascript" src="../../../lib/godoc/jquery.js"></script>
  805. <script type="text/javascript" src="../../../lib/godoc/jquery.treeview.js"></script>
  806. <script type="text/javascript" src="../../../lib/godoc/jquery.treeview.edit.js"></script>
  807. <script type="text/javascript" src="../../../lib/godoc/godocs.js"></script>
  808. </body>
  809. </html>