Package io.kubernetes.client.util
Class CSRUtils
java.lang.Object
io.kubernetes.client.util.CSRUtils
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidApproves a CertificateSigningRequest by requesting "/approve" subresource.static byte[]createAndWaitUntilCertificateSigned(io.kubernetes.client.openapi.ApiClient bootstrapApiClient, io.kubernetes.client.openapi.models.V1CertificateSigningRequest csr) Creates the given CertificateSigningRequest object if it doesn't exist, then waits until it's approved.static booleancreateIfAbsent(io.kubernetes.client.openapi.ApiClient apiClient, io.kubernetes.client.openapi.models.V1CertificateSigningRequest csr) Creates if the CertificateSigningRequest is absent in the cluster.static Optional<byte[]>getCertificate(io.kubernetes.client.openapi.models.V1CertificateSigningRequest csr) Gets certificate data from the CertificateSigningRequest object.static booleanisIdentical(io.kubernetes.client.openapi.models.V1CertificateSigningRequest left, io.kubernetes.client.openapi.models.V1CertificateSigningRequest right) Checks if the two CertificateSigningRequest is identical.static io.kubernetes.client.openapi.models.V1CertificateSigningRequestnewV1CertificateSigningRequest(String csrObjName, byte[] csrBytes) static io.kubernetes.client.openapi.models.V1CertificateSigningRequestnewV1CertificateSigningRequest(String csrObjName, byte[] csrBytes, String signerName, String usage) static byte[]Sign CSR from the key-pair.static byte[]Sign CSR from the key-pair.static byte[]Sign CSR from the key-pair.static byte[]waitUntilCertificateSigned(io.kubernetes.client.openapi.ApiClient apiClient, String csrObjectName) Wait until the CertificateSigningRequest is approved within a timeout of 30 minutes.static byte[]waitUntilCertificateSigned(io.kubernetes.client.openapi.ApiClient apiClient, String csrObjectName, Duration retryInterval, Duration timeout) Wait until the CertificateSigningRequest is approved within a timeout of 30 minutes.
-
Field Details
-
CSR_USAGE_CLIENT_AUTH
- See Also:
-
SIGNER_NAME_KUBE_APISERVER_CLIENT
- See Also:
-
-
Constructor Details
-
CSRUtils
public CSRUtils()
-
-
Method Details
-
approve
public static void approve(io.kubernetes.client.openapi.ApiClient apiClient, String csrObjName) throws io.kubernetes.client.openapi.ApiException Approves a CertificateSigningRequest by requesting "/approve" subresource.- Parameters:
apiClient- the api clientcsrObjName- the csr obj name- Throws:
io.kubernetes.client.openapi.ApiException- the api exception
-
createAndWaitUntilCertificateSigned
public static byte[] createAndWaitUntilCertificateSigned(io.kubernetes.client.openapi.ApiClient bootstrapApiClient, io.kubernetes.client.openapi.models.V1CertificateSigningRequest csr) throws CSRNotApprovedException, io.kubernetes.client.openapi.ApiException Creates the given CertificateSigningRequest object if it doesn't exist, then waits until it's approved.It's short-cut combo of CSRUtils#createIfAbsent and CSRUtils#waitUntilCertificateSigned
- Parameters:
bootstrapApiClient- the bootstrap api clientcsr- the csr- Returns:
- the bytes of CSR [ ]
- Throws:
CSRNotApprovedException- the csr not approved exceptionio.kubernetes.client.openapi.ApiException- the api exception
-
createIfAbsent
public static boolean createIfAbsent(io.kubernetes.client.openapi.ApiClient apiClient, io.kubernetes.client.openapi.models.V1CertificateSigningRequest csr) throws io.kubernetes.client.openapi.ApiException Creates if the CertificateSigningRequest is absent in the cluster.- Parameters:
apiClient- the api clientcsr- the csr- Returns:
- the boolean represents whether the CSR is actually created.
- Throws:
io.kubernetes.client.openapi.ApiException- the api exception
-
waitUntilCertificateSigned
public static byte[] waitUntilCertificateSigned(io.kubernetes.client.openapi.ApiClient apiClient, String csrObjectName) throws CSRNotApprovedException Wait until the CertificateSigningRequest is approved within a timeout of 30 minutes.- Parameters:
apiClient- the api clientcsrObjectName- the csr object name- Returns:
- the byte [ ]
- Throws:
CSRNotApprovedException- the csr not approved exception
-
waitUntilCertificateSigned
public static byte[] waitUntilCertificateSigned(io.kubernetes.client.openapi.ApiClient apiClient, String csrObjectName, Duration retryInterval, Duration timeout) throws CSRNotApprovedException Wait until the CertificateSigningRequest is approved within a timeout of 30 minutes.- Parameters:
apiClient- the api clientcsrObjectName- the csr object nameretryInterval- the retry intervaltimeout- the timeout- Returns:
- the byte [ ]
- Throws:
CSRNotApprovedException- the csr not approved exception
-
getCertificate
public static Optional<byte[]> getCertificate(io.kubernetes.client.openapi.models.V1CertificateSigningRequest csr) Gets certificate data from the CertificateSigningRequest object.- Parameters:
csr- the csr- Returns:
- the certificate
-
isIdentical
public static boolean isIdentical(io.kubernetes.client.openapi.models.V1CertificateSigningRequest left, io.kubernetes.client.openapi.models.V1CertificateSigningRequest right) Checks if the two CertificateSigningRequest is identical.- Parameters:
left- the leftright- the right- Returns:
- the boolean
-
sign
Sign CSR from the key-pair.- Parameters:
keyPair- the key paircommonName- the common name- Returns:
- the byte [ ]
- Throws:
CSRSigningException- the csr signing exception
-
sign
public static byte[] sign(KeyPair keyPair, String csrAlgo, String commonName, String organizationName) throws CSRSigningException Sign CSR from the key-pair.- Parameters:
keyPair- the key paircsrAlgo- the csr algocommonName- the common nameorganizationName- the organization name- Returns:
- the byte [ ]
- Throws:
CSRSigningException- the csr signing exception
-
sign
public static byte[] sign(KeyPair keyPair, String csrAlgo, String subjects) throws CSRSigningException Sign CSR from the key-pair.- Parameters:
keyPair- the key paircsrAlgo- the csr algosubjects- the subjects- Returns:
- the byte [ ]
- Throws:
CSRSigningException- the csr signing exception
-
newV1CertificateSigningRequest
public static io.kubernetes.client.openapi.models.V1CertificateSigningRequest newV1CertificateSigningRequest(String csrObjName, byte[] csrBytes) -
newV1CertificateSigningRequest
-